From 533fa895158b47c2535f31cdd1b2029cb88df2cf Mon Sep 17 00:00:00 2001 From: aCaB Date: Sun, 8 Feb 2009 15:45:38 +0000 Subject: [PATCH] do not infloop git-svn-id: file:///var/lib/svn/clamav-devel/branches/clamd-proto@4707 77e5149b-7576-45b1-b177-96237e5ba77b --- clamdscan/client.c | 1 + clamdscan/proto.c | 21 +++++++++++---------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/clamdscan/client.c b/clamdscan/client.c index a75d45a6b..54d61d898 100644 --- a/clamdscan/client.c +++ b/clamdscan/client.c @@ -266,6 +266,7 @@ int client(const struct optstruct *opts, int *infected) scandash = (opts->filename && opts->filename[0] && !strcmp(opts->filename[0], "-") && !opts->filename[1]); remote = isremote(opts); + // remote = 1; /* FIXME : get rid of me */ #ifdef HAVE_FD_PASSING if(!remote && optget(clamdopts, "LocalSocket")->enabled && (optget(opts, "fdpass")->enabled || scandash)) { scantype = FILDES; diff --git a/clamdscan/proto.c b/clamdscan/proto.c index c70435eda..87783a332 100644 --- a/clamdscan/proto.c +++ b/clamdscan/proto.c @@ -405,9 +405,9 @@ int dspresult(struct client_parallel_data *c) { recvlninit(&rcv, c->sockd); do { len = recvln(&rcv, &bol, &eol); - if(len == -1) { + if(!bol || len == -1) { c->errors++; - break; + return 1; } if(!bol) return 0; if((rid = atoi(bol))) { @@ -544,17 +544,18 @@ int parallel_client_scan(const char *file, int scantype, int *infected, int *err cli_ftw(file, CLI_FTW_STD, maxlevel ? maxlevel : INT_MAX, parallel_callback, &data); /* FIXME: check return */ - while(cdata.ids) { - if(dspresult(&cdata)) { /* FIXME: return something */ } - }; - sendln(cdata.sockd, "zEND", 5); + while(cdata.ids && !dspresult(&cdata)); close(cdata.sockd); - if(!printinfected && !cdata.infected && (!cdata.errors || cdata.spam)) - logg("~%s: OK\n", file); - + if(cdata.ids) { + logg("!Clamd closed connection before scannign all files. ERROR\n"); + } else { + if(!printinfected && !cdata.infected && (!cdata.errors || cdata.spam)) + logg("~%s: OK\n", file); + } + *infected += cdata.infected; *errors += cdata.errors; - return 0; + return (!!cdata.ids); }