Browse code

fclose on error

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

Nigel Horne authored on 2004/09/09 01:02:34
Showing 1 changed files
... ...
@@ -20,6 +20,9 @@
20 20
  *
21 21
  * Change History:
22 22
  * $Log: untar.c,v $
23
+ * Revision 1.6  2004/09/08 16:02:34  nigelhorne
24
+ * fclose on error
25
+ *
23 26
  * Revision 1.5  2004/09/06 14:16:48  nigelhorne
24 27
  * Added CYGWIN support
25 28
  *
... ...
@@ -36,7 +39,7 @@
36 36
  * First draft
37 37
  *
38 38
  */
39
-static	char	const	rcsid[] = "$Id: untar.c,v 1.5 2004/09/06 14:16:48 nigelhorne Exp $";
39
+static	char	const	rcsid[] = "$Id: untar.c,v 1.6 2004/09/08 16:02:34 nigelhorne Exp $";
40 40
 
41 41
 #include <stdio.h>
42 42
 #include <errno.h>
... ...
@@ -94,6 +97,8 @@ cli_untar(const char *dir, int desc)
94 94
 			break;
95 95
 
96 96
 		if(nread != BLOCKSIZE) {
97
+			if(outfile)
98
+				fclose(outfile);
97 99
 			cli_errmsg("cli_untar: incomplete block read\n");
98 100
 			return CL_EIO;
99 101
 		}
... ...
@@ -189,7 +194,7 @@ cli_untar(const char *dir, int desc)
189 189
 			strncpy(osize, block+124, 12);
190 190
 			osize[12] = '\0';
191 191
 			size = octal(osize);
192
-			if(size < 0){
192
+			if(size < 0) {
193 193
 				cli_errmsg("Invalid size in tar header\n");
194 194
 				fclose(outfile);
195 195
 				return CL_EDSIG;