Browse code

bb11418 - fix clamdscan segfault when using stream(stdin) input.

Steven Morgan authored on 2015/10/31 01:48:26
Showing 2 changed files
... ...
@@ -47,6 +47,7 @@ Andreas Cadhalpun
47 47
 Dmitry Marakasov
48 48
 Michael Pelletier
49 49
 Felix Groebert
50
+Stephen Welker
50 51
 
51 52
 --
52 53
 The ClamAV team (http://www.clamav.net/about.html#credits)
... ...
@@ -325,10 +325,14 @@ int dsresult(int sockd, int scantype, const char *filename, int *printok, int *e
325 325
                 static char last_filename[PATH_MAX+1] = {'\0'};
326 326
 		*(eol - 7) = 0;
327 327
 		*printok = 0;
328
-                if (scantype != ALLMATCH || filename != NULL && strcmp(filename, last_filename)) {
328
+                if (scantype != ALLMATCH) {
329 329
                     infected++;
330
-                    strncpy(last_filename, filename, PATH_MAX);
331
-                    last_filename[PATH_MAX] = '\0';
330
+                } else {
331
+                    if (filename != NULL && strcmp(filename, last_filename)) {
332
+                        infected++;
333
+                        strncpy(last_filename, filename, PATH_MAX);
334
+                        last_filename[PATH_MAX] = '\0';
335
+                    }
332 336
                 }
333 337
 		if(filename) {
334 338
 		    if(scantype >= STREAM) {