Browse code

fix error path descriptor leaks

git-svn: trunk@3573

Tomasz Kojm authored on 2008/02/02 18:42:12
Showing 2 changed files
... ...
@@ -1,3 +1,7 @@
1
+Sat Feb  2 10:22:45 CET 2008 (tk)
2
+---------------------------------
3
+  * libclamav/cab.c: fix error path descriptor leaks
4
+
1 5
 Fri Feb  1 21:19:58 EET 2008 (edwin)
2 6
 ------------------------------------
3 7
   * libclamav/filetypes.c: use entconv to detect UTF-16BE, and UCS-4 variants
... ...
@@ -623,11 +623,13 @@ static int cab_unstore(struct cab_file *file, int bytes)
623 623
 	}								\
624 624
 	if(lseek(file->fd, file->folder->offset, SEEK_SET) == -1) {	\
625 625
 	    cli_dbgmsg("cab_extract: Can't lseek to %u\n", (unsigned int) file->folder->offset);							\
626
+	    close(file->ofd);						\
626 627
 	    return CL_EFORMAT; /* truncated file? */			\
627 628
 	}								\
628 629
 	file->cab->state = (struct cab_state *) cli_calloc(1, sizeof(struct cab_state));								\
629 630
 	if(!file->cab->state) {						\
630 631
 	    cli_errmsg("cab_extract: Can't allocate memory for internal state\n");									\
632
+	    close(file->ofd);						\
631 633
 	    return CL_EMEM;						\
632 634
 	}								\
633 635
 	file->cab->state->cmethod = file->folder->cmethod;		\