Browse code

handle error conditions of cli_scandesc()

git-svn-id: file:///var/lib/svn/clamav-devel/trunk/clamav-devel@1070 77e5149b-7576-45b1-b177-96237e5ba77b

Tomasz Kojm authored on 2004/11/08 18:03:33
Showing 2 changed files
... ...
@@ -1,3 +1,7 @@
1
+Mon Nov  8 10:01:48 CET 2004 (tk)
2
+---------------------------------
3
+  * libclamav/scanners.c: handle error conditions of cli_scandesc()
4
+
1 5
 Sun Nov  7 16:42:10 GMT 2004 (njh)
2 6
 ----------------------------------
3 7
   * libclamav/message.c:	Handle paragraph 4 of RFC2231
... ...
@@ -141,9 +141,13 @@ static int cli_scanrar(int desc, const char **virname, long int *scanned, const
141 141
 	    files++;
142 142
 	    cli_dbgmsg("RAR: Encrypted files found in archive.\n");
143 143
 	    lseek(desc, 0, SEEK_SET);
144
-	    if(cli_scandesc(desc, virname, scanned, root, 0, 0) != CL_VIRUS)
144
+	    ret = cli_scandesc(desc, virname, scanned, root, 0, 0);
145
+	    if(ret < 0) {
146
+		break;
147
+	    } else if(ret != CL_VIRUS) {
145 148
 		*virname = "Encrypted.RAR";
146
-	    ret = CL_VIRUS;
149
+		ret = CL_VIRUS;
150
+	    }
147 151
 	    break;
148 152
 	}
149 153
 
... ...
@@ -332,9 +336,13 @@ static int cli_scanzip(int desc, const char **virname, long int *scanned, const
332 332
 	    files++;
333 333
 	    cli_dbgmsg("Zip: Encrypted files found in archive.\n");
334 334
 	    lseek(desc, 0, SEEK_SET);
335
-	    if(cli_scandesc(desc, virname, scanned, root, 0, 0) != CL_VIRUS)
335
+	    ret = cli_scandesc(desc, virname, scanned, root, 0, 0);
336
+	    if(ret < 0) {
337
+		break;
338
+	    } else if(ret != CL_VIRUS) {
336 339
 		*virname = "Encrypted.Zip";
337
-	    ret = CL_VIRUS;
340
+		ret = CL_VIRUS;
341
+	    }
338 342
 	    break;
339 343
 	}
340 344
 
... ...
@@ -728,6 +736,13 @@ static int cli_scanhtml(int desc, const char **virname, long int *scanned, const
728 728
 	close(fd);
729 729
     }
730 730
 
731
+    if(ret < 0 || ret == CL_VIRUS) {
732
+	if(!cli_leavetemps_flag)
733
+	    cli_rmdirs(tempname);
734
+	free(tempname);
735
+	return ret;
736
+    }
737
+
731 738
     if (ret == CL_CLEAN) {
732 739
 	snprintf(fullname, 1024, "%s/nocomment.html", tempname);
733 740
 	fd = open(fullname, O_RDONLY);
... ...
@@ -737,6 +752,13 @@ static int cli_scanhtml(int desc, const char **virname, long int *scanned, const
737 737
 	}
738 738
     }
739 739
 
740
+    if(ret < 0 || ret == CL_VIRUS) {
741
+	if(!cli_leavetemps_flag)
742
+	    cli_rmdirs(tempname);
743
+	free(tempname);
744
+	return ret;
745
+    }
746
+
740 747
     if (ret == CL_CLEAN) {
741 748
 	snprintf(fullname, 1024, "%s/script.html", tempname);
742 749
 	fd = open(fullname, O_RDONLY);
... ...
@@ -1280,6 +1302,9 @@ int cli_magic_scandesc(int desc, const char **virname, long int *scanned, const
1280 1280
 	    cli_dbgmsg("%s found in descriptor %d.\n", *virname, desc);
1281 1281
 	    return CL_VIRUS;
1282 1282
 
1283
+	} else if(nret < 0) {
1284
+	    return nret;
1285
+
1283 1286
 	} else if(nret >= CL_TYPENO) {
1284 1287
 	    lseek(desc, 0, SEEK_SET);
1285 1288