Browse code

do not infloop

git-svn-id: file:///var/lib/svn/clamav-devel/branches/clamd-proto@4707 77e5149b-7576-45b1-b177-96237e5ba77b

aCaB authored on 2009/02/09 00:45:38
Showing 2 changed files
... ...
@@ -266,6 +266,7 @@ int client(const struct optstruct *opts, int *infected)
266 266
 
267 267
     scandash = (opts->filename && opts->filename[0] && !strcmp(opts->filename[0], "-") && !opts->filename[1]);
268 268
     remote = isremote(opts);
269
+    //    remote = 1; /* FIXME : get rid of me */
269 270
 #ifdef HAVE_FD_PASSING
270 271
     if(!remote && optget(clamdopts, "LocalSocket")->enabled && (optget(opts, "fdpass")->enabled || scandash)) {
271 272
 	scantype = FILDES;
... ...
@@ -405,9 +405,9 @@ int dspresult(struct client_parallel_data *c) {
405 405
     recvlninit(&rcv, c->sockd);
406 406
     do {
407 407
 	len = recvln(&rcv, &bol, &eol);
408
-	if(len == -1) {
408
+	if(!bol || len == -1) {
409 409
 	    c->errors++;
410
-	    break;
410
+	    return 1;
411 411
 	}
412 412
 	if(!bol) return 0;
413 413
 	if((rid = atoi(bol))) {
... ...
@@ -544,17 +544,18 @@ int parallel_client_scan(const char *file, int scantype, int *infected, int *err
544 544
     cli_ftw(file, CLI_FTW_STD, maxlevel ? maxlevel : INT_MAX, parallel_callback, &data);
545 545
     /* FIXME: check return */
546 546
 
547
-    while(cdata.ids) {
548
-	if(dspresult(&cdata)) { /* FIXME: return something */ }
549
-    };
550
-
551 547
     sendln(cdata.sockd, "zEND", 5);
548
+    while(cdata.ids && !dspresult(&cdata));
552 549
     close(cdata.sockd);
553 550
 
554
-    if(!printinfected && !cdata.infected && (!cdata.errors || cdata.spam))
555
-	logg("~%s: OK\n", file);
556
-
551
+    if(cdata.ids) {
552
+	logg("!Clamd closed connection before scannign all files. ERROR\n");
553
+    } else {
554
+	if(!printinfected && !cdata.infected && (!cdata.errors || cdata.spam))
555
+	    logg("~%s: OK\n", file);
556
+    }
557
+    
557 558
     *infected += cdata.infected;
558 559
     *errors += cdata.errors;
559
-    return 0;
560
+    return (!!cdata.ids);
560 561
 }