From 1464e7a16910f1d7dea0ff4aebf88f56f9fbf26a Mon Sep 17 00:00:00 2001 From: Tomasz Kojm Date: Wed, 5 Nov 2008 19:50:28 +0000 Subject: [PATCH] clamscan/manager.c: fix double-slash when scanning the root dir (bb#1263) git-svn: trunk@4342 --- ChangeLog | 4 ++++ clamscan/manager.c | 10 ++++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index ace41782b..56db37b59 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +Wed Nov 5 21:20:56 CET 2008 (tk) +--------------------------------- + * clamscan/manager.c: fix double-slash when scanning the root dir (bb#1263) + Wed Nov 5 19:54:42 CET 2008 (tk) --------------------------------- * unit_tests/virusaction-test.sh: ignore pathnames (bb#1274) diff --git a/clamscan/manager.c b/clamscan/manager.c index a8d5a1e41..5c7cac452 100644 --- a/clamscan/manager.c +++ b/clamscan/manager.c @@ -242,7 +242,10 @@ static int scandirs(const char *dirname, struct cl_engine *engine, const struct if(strcmp(dent->d_name, ".") && strcmp(dent->d_name, "..")) { /* build the full name */ fname = malloc(strlen(dirname) + strlen(dent->d_name) + 2); - sprintf(fname, "%s/%s", dirname, dent->d_name); + if(!strcmp(dirname, "/")) + sprintf(fname, "/%s", dent->d_name); + else + sprintf(fname, "%s/%s", dirname, dent->d_name); /* stat the file */ if(lstat(fname, &statbuf) != -1) { @@ -619,12 +622,11 @@ int scanmanager(const struct optstruct *opt) perror(file); ret = 56; } else { - int slash = 1; - for(i = strlen(file) - 1; i > 0 && slash; i--) { + for(i = strlen(file) - 1; i > 0; i--) { if(file[i] == '/') file[i] = 0; else - slash = 0; + break; } fmode = (mode_t) fmodeint;