Browse code

scaniso do not dump whole secotrs

aCaB authored on 2011/11/23 03:08:37
Showing 2 changed files
... ...
@@ -1,3 +1,7 @@
1
+Tue Nov 22 19:07:47 CET 2011 (acab)
2
+-----------------------------------
3
+ * libclamav/io9660.c: properly dump to temp file
4
+
1 5
 Fri Nov 18 15:23:50 CET 2011 (tk)
2 6
 ---------------------------------
3 7
  * libclamav/scanners.c: use lsigs when scanning vba data (bb#3922)
... ...
@@ -54,13 +54,14 @@ static void *needblock(const iso9660_t *iso, unsigned int block, int temp) {
54 54
 static int iso_scan_file(const iso9660_t *iso, unsigned int block, unsigned int len) {
55 55
     char *tmpf;
56 56
     int fd, ret;
57
-    if(cli_gentempfd(NULL, &tmpf, &fd) != CL_SUCCESS)
57
+    if(cli_gentempfd(iso->ctx->engine->tmpdir, &tmpf, &fd) != CL_SUCCESS)
58 58
 	return CL_ETMPFILE;
59 59
 
60 60
     cli_dbgmsg("iso_scan_file: dumping to %s\n", tmpf);
61 61
     while(len) {
62 62
 	void *buf = needblock(iso, block, 1);
63
-	if(cli_writen(fd, buf, iso->blocksz) != iso->blocksz) {
63
+	unsigned int todo = MIN(len, iso->blocksz);
64
+	if(cli_writen(fd, buf, todo) != todo) {
64 65
 	    close(fd);
65 66
 	    ret = cli_unlink(tmpf);
66 67
 	    free(tmpf);
... ...
@@ -68,7 +69,7 @@ static int iso_scan_file(const iso9660_t *iso, unsigned int block, unsigned int
68 68
 		return CL_EUNLINK;
69 69
 	    return CL_EWRITE;
70 70
 	}
71
-	len -= MIN(len, iso->blocksz);
71
+	len -= todo;
72 72
 	block++;
73 73
     }
74 74