mirror of
https://github.com/Cisco-Talos/clamav.git
synced 2025-10-19 18:33:16 +00:00
trim extra leading and trailing slashes (bb #1423).
git-svn: trunk@4852
This commit is contained in:
parent
5dddbcb787
commit
a1598d7ccb
6 changed files with 28 additions and 8 deletions
|
@ -1,3 +1,9 @@
|
||||||
|
Tue Feb 24 15:54:17 EET 2009 (edwin)
|
||||||
|
------------------------------------
|
||||||
|
* clamdscan/client.c, clamdscan/proto.c, clamdscan/proto.h,
|
||||||
|
libclamav/others.h, libclamav/others_common.c: trim extra leading
|
||||||
|
and trailing slashes (bb #1423).
|
||||||
|
|
||||||
Tue Feb 24 12:32:03 EET 2009 (edwin)
|
Tue Feb 24 12:32:03 EET 2009 (edwin)
|
||||||
------------------------------------
|
------------------------------------
|
||||||
* unit_tests/efence_tests.sh: fix electric-fence return code
|
* unit_tests/efence_tests.sh: fix electric-fence return code
|
||||||
|
|
|
@ -242,6 +242,7 @@ int client(const struct optstruct *opts, int *infected)
|
||||||
flags |= CLI_FTW_FOLLOW_DIR_SYMLINK;
|
flags |= CLI_FTW_FOLLOW_DIR_SYMLINK;
|
||||||
if (optget(clamdopts, "FollowFileSymlinks")->enabled)
|
if (optget(clamdopts, "FollowFileSymlinks")->enabled)
|
||||||
flags |= CLI_FTW_FOLLOW_FILE_SYMLINK;
|
flags |= CLI_FTW_FOLLOW_FILE_SYMLINK;
|
||||||
|
flags |= CLI_FTW_TRIM_SLASHES;
|
||||||
optfree(clamdopts);
|
optfree(clamdopts);
|
||||||
|
|
||||||
if(!mainsa) {
|
if(!mainsa) {
|
||||||
|
|
|
@ -370,7 +370,7 @@ static int serial_callback(struct stat *sb, char *filename, const char *path, en
|
||||||
|
|
||||||
/* Non-IDSESSION handler
|
/* Non-IDSESSION handler
|
||||||
* Returns non zero for serious errors, zero otherwise */
|
* Returns non zero for serious errors, zero otherwise */
|
||||||
int serial_client_scan(const char *file, int scantype, int *infected, int *errors, int maxlevel, int flags) {
|
int serial_client_scan(char *file, int scantype, int *infected, int *errors, int maxlevel, int flags) {
|
||||||
struct cli_ftw_cbdata data;
|
struct cli_ftw_cbdata data;
|
||||||
struct client_serial_data cdata;
|
struct client_serial_data cdata;
|
||||||
int ftw;
|
int ftw;
|
||||||
|
@ -547,7 +547,7 @@ static int parallel_callback(struct stat *sb, char *filename, const char *path,
|
||||||
|
|
||||||
/* IDSESSION handler
|
/* IDSESSION handler
|
||||||
* Returns non zero for serious errors, zero otherwise */
|
* Returns non zero for serious errors, zero otherwise */
|
||||||
int parallel_client_scan(const char *file, int scantype, int *infected, int *errors, int maxlevel, int flags) {
|
int parallel_client_scan(char *file, int scantype, int *infected, int *errors, int maxlevel, int flags) {
|
||||||
struct cli_ftw_cbdata data;
|
struct cli_ftw_cbdata data;
|
||||||
struct client_parallel_data cdata;
|
struct client_parallel_data cdata;
|
||||||
int ftw;
|
int ftw;
|
||||||
|
|
|
@ -34,7 +34,7 @@ int dconnect(void);
|
||||||
int sendln(int sockd, const char *line, unsigned int len);
|
int sendln(int sockd, const char *line, unsigned int len);
|
||||||
void recvlninit(struct RCVLN *s, int sockd);
|
void recvlninit(struct RCVLN *s, int sockd);
|
||||||
int recvln(struct RCVLN *s, char **rbol, char **reol);
|
int recvln(struct RCVLN *s, char **rbol, char **reol);
|
||||||
int serial_client_scan(const char *file, int scantype, int *infected, int *errors, int maxlevel, int flags);
|
int serial_client_scan(char *file, int scantype, int *infected, int *errors, int maxlevel, int flags);
|
||||||
int parallel_client_scan(const char *file, int scantype, int *infected, int *errors, int maxlevel, int flags);
|
int parallel_client_scan(char *file, int scantype, int *infected, int *errors, int maxlevel, int flags);
|
||||||
int dsresult(int sockd, int scantype, const char *filename);
|
int dsresult(int sockd, int scantype, const char *filename);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -372,7 +372,9 @@ int cli_matchregex(const char *str, const char *regex);
|
||||||
/* if the callback needs the stat */
|
/* if the callback needs the stat */
|
||||||
#define CLI_FTW_NEED_STAT 0x04
|
#define CLI_FTW_NEED_STAT 0x04
|
||||||
|
|
||||||
#define CLI_FTW_STD (CLI_FTW_NEED_STAT)
|
/* remove leading/trailing slashes */
|
||||||
|
#define CLI_FTW_TRIM_SLASHES 0x08
|
||||||
|
#define CLI_FTW_STD (CLI_FTW_NEED_STAT | CLI_FTW_TRIM_SLASHES)
|
||||||
|
|
||||||
enum cli_ftw_reason {
|
enum cli_ftw_reason {
|
||||||
visit_file,
|
visit_file,
|
||||||
|
@ -414,6 +416,6 @@ typedef int (*cli_ftw_cb)(struct stat *stat_buf, char *filename, const char *pat
|
||||||
* which one it is.
|
* which one it is.
|
||||||
* If it is a file, it simply calls the callback once, otherwise recurses.
|
* If it is a file, it simply calls the callback once, otherwise recurses.
|
||||||
*/
|
*/
|
||||||
int cli_ftw(const char *base, int flags, int maxdepth, cli_ftw_cb callback, struct cli_ftw_cbdata *data);
|
int cli_ftw(char *base, int flags, int maxdepth, cli_ftw_cb callback, struct cli_ftw_cbdata *data);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -496,14 +496,25 @@ static int handle_entry(struct dirent_data *entry, int flags, int maxdepth, cli_
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int cli_ftw(const char *path, int flags, int maxdepth, cli_ftw_cb callback, struct cli_ftw_cbdata *data)
|
int cli_ftw(char *path, int flags, int maxdepth, cli_ftw_cb callback, struct cli_ftw_cbdata *data)
|
||||||
{
|
{
|
||||||
struct stat statbuf;
|
struct stat statbuf;
|
||||||
enum filetype ft = ft_unknown;
|
enum filetype ft = ft_unknown;
|
||||||
struct dirent_data entry;
|
struct dirent_data entry;
|
||||||
int stated = 0;
|
int stated = 0;
|
||||||
|
|
||||||
int ret = handle_filetype(path, flags, &statbuf, &stated, &ft, callback, data);
|
int ret;
|
||||||
|
|
||||||
|
if (flags & CLI_FTW_TRIM_SLASHES) {
|
||||||
|
/* trim slashes so that dir and dir/ behave the same when
|
||||||
|
* they are symlinks, and we are not following symlinks */
|
||||||
|
char *pathend;
|
||||||
|
while (path[0] == '/' && path[1] == '/') path++;
|
||||||
|
pathend = path + strlen(path);
|
||||||
|
while (pathend > path && pathend[-1] == '/') --pathend;
|
||||||
|
*pathend = '\0';
|
||||||
|
}
|
||||||
|
ret = handle_filetype(path, flags, &statbuf, &stated, &ft, callback, data);
|
||||||
if (ret != CL_SUCCESS)
|
if (ret != CL_SUCCESS)
|
||||||
return ret;
|
return ret;
|
||||||
if (ft_skipped(ft))
|
if (ft_skipped(ft))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue