Browse code

* libclamav/chmunpack.c: Fix possible memory leak (TK) * libclamav/vba_extract.c: Fix zero allocation warning.

git-svn: trunk@1680

Trog authored on 2005/08/03 17:58:25
Showing 3 changed files
... ...
@@ -1,3 +1,9 @@
1
+Wed Aug  3 09:56:33 BST 2005 (trog)
2
+-----------------------------------
3
+  * libclamav/chmunpack.c: Fix possible memory leak (TK)
4
+
5
+  * libclamav/vba_extract.c: Fix zero allocation warning.
6
+
1 7
 Wed Aug  3 04:57:36 CEST 2005 (tk)
2 8
 ----------------------------------
3 9
   * freshclam: add new option --on-update-execute (OnUpdateExecute). Requested
... ...
@@ -482,12 +482,11 @@ static int read_chunk_entries(unsigned char *chunk, uint32_t chunk_len,
482 482
 		name_len = read_enc_int(&current, end);
483 483
 		if (name_len > 0xFFFFFF) {
484 484
 			cli_dbgmsg("CHM file name too long: %llu\n", name_len);
485
-			file_e->name = (unsigned char *) cli_malloc(10);
485
+			file_e->name = (unsigned char *) strdup("truncated");
486 486
 	                if (!file_e->name) {
487 487
         	                free(file_e);
488 488
                 	        return FALSE;
489 489
                 	}
490
-			file_e->name = strdup("truncated");
491 490
 		} else {
492 491
 			file_e->name = (unsigned char *) cli_malloc(name_len+1);
493 492
 			if (!file_e->name) {
... ...
@@ -451,6 +451,10 @@ vba_project_t *vba56_dir_read(const char *dir)
451 451
 	}
452 452
 	record_count = vba_endian_convert_16(record_count, is_mac);
453 453
 	cli_dbgmsg("\nVBA Record count: %d\n", record_count);
454
+	if (record_count == 0) {
455
+		close(fd);
456
+                return NULL;
457
+        }
454 458
 	if (record_count > 1000) {
455 459
 		/* Almost certainly an error */
456 460
 		cli_dbgmsg("\nVBA Record count too big");