Browse code

error path leaks and similar stuff

aCaB authored on 2010/12/17 22:26:33
Showing 4 changed files
... ...
@@ -1,3 +1,8 @@
1
+Fri Dec 17 14:21:21 CET 2010 (acab)
2
+-----------------------------------
3
+ * clamav-milter/whitelist.c, clamscan/manager.c, libclamav/sis.c:
4
+   error path leaks and similar - thanks Michael Tautschnig <mt*debian.org>
5
+	
1 6
 Thu Dec 16 15:31:38 CET 2010 (acab)
2 7
 ---------------------------------
3 8
  * clamav-milter: handle EINTR during waitpid()
... ...
@@ -90,6 +90,7 @@ int whitelist_init(const char *fname) {
90 90
 	if (!(w = (struct WHLST *)malloc(sizeof(*w)))) {
91 91
 	    logg("!Out of memory loading whitelist file\n");
92 92
 	    whitelist_free();
93
+	    fclose(f);
93 94
 	    return 1;
94 95
 	}
95 96
 	w->next = (*addto);
... ...
@@ -97,9 +98,11 @@ int whitelist_init(const char *fname) {
97 97
 	if (cli_regcomp(&w->preg, ptr, REG_ICASE|REG_NOSUB)) {
98 98
 	    logg("!Failed to compile regex '%s' in whitelist file\n", ptr);
99 99
 	    whitelist_free();
100
+	    fclose(f);
100 101
 	    return 1;
101 102
 	}
102 103
     }
104
+    fclose(f);
103 105
     return 0;
104 106
 }
105 107
 
... ...
@@ -273,6 +273,7 @@ static int scanstdin(const struct cl_engine *engine, const struct optstruct *opt
273 273
 	if(fwrite(buff, 1, bread, fs) < bread) {
274 274
 	    logg("!Can't write to %s\n", file);
275 275
 	    free(file);
276
+	    fclose(fs);
276 277
 	    return 2;
277 278
 	}
278 279
     }
... ...
@@ -506,7 +506,6 @@ static int real_scansis(FILE *f, cli_ctx *ctx, const char *tmpd) {
506 506
 	    free(decomp);
507 507
 	    free(ptrs);
508 508
 	    free(alangs);
509
-	    close(fd);
510 509
 	    return CL_EWRITE;
511 510
 	  }
512 511
 	  free(decomp);