Browse code

bb#384

git-svn: trunk@3750

aCaB authored on 2008/04/03 00:53:10
Showing 5 changed files
... ...
@@ -1,3 +1,7 @@
1
+Wed Apr  2 16:38:36 CEST 2008 (acab)
2
+------------------------------------
3
+  * libclamav: check return codes from syscalls (bb#384)
4
+
1 5
 Wed Apr  2 16:34:43 CEST 2008 (tk)
2 6
 ----------------------------------
3 7
   * libclamav: update copyrights and stick more files to GPLv2; move and add
... ...
@@ -439,8 +439,7 @@ fileblobDestructiveDestroy(fileblob *fb)
439 439
 	if(fb->fp && fb->fullname) {
440 440
 		fclose(fb->fp);
441 441
 		cli_dbgmsg("fileblobDestructiveDestroy: %s\n", fb->fullname);
442
-		if(cli_unlink(fb->fullname) < 0)
443
-			cli_warnmsg("fileblobDestructiveDestroy: Can't delete file %s\n", fb->fullname);
442
+		cli_unlink(fb->fullname);
444 443
 		free(fb->fullname);
445 444
 		fb->fp = NULL;
446 445
 		fb->fullname = NULL;
... ...
@@ -468,8 +467,7 @@ fileblobDestroy(fileblob *fb)
468 468
 			cli_dbgmsg("fileblobDestroy: %s\n", fb->fullname);
469 469
 			if(!fb->isNotEmpty) {
470 470
 				cli_dbgmsg("fileblobDestroy: not saving empty file\n");
471
-				if(cli_unlink(fb->fullname) < 0)
472
-					cli_warnmsg("fileblobDestroy: Can't delete empty file %s\n", fb->fullname);
471
+				cli_unlink(fb->fullname); 
473 472
 			}
474 473
 		}
475 474
 		free(fb->b.name);
... ...
@@ -3851,8 +3851,7 @@ rfc1341(message *m, const char *dir)
3851 3851
 						if(stat(fullname, &statb) < 0)
3852 3852
 							continue;
3853 3853
 						if(now - statb.st_mtime > (time_t)(7 * 24 * 3600))
3854
-							if(cli_unlink(fullname) >= 0)
3855
-								cli_dbgmsg("removed old RFC1341 file %s\n", fullname);
3854
+							cli_unlink(fullname);
3856 3855
 						continue;
3857 3856
 					}
3858 3857
 
... ...
@@ -3876,10 +3875,18 @@ rfc1341(message *m, const char *dir)
3876 3876
 							nblanks++;
3877 3877
 						else {
3878 3878
 							if(nblanks)
3879
-								do
3880
-									putc('\n', fout);
3881
-								while(--nblanks > 0);
3882
-							fputs(buffer, fout);
3879
+								do {
3880
+									if (putc('\n', fout)==EOF) break;
3881
+								} while(--nblanks > 0);
3882
+							if (nblanks || fputs(buffer, fout)==EOF) {
3883
+								fclose(fin);
3884
+								fclose(fout);
3885
+								cli_unlink(outname);
3886
+								free(id);
3887
+								free(number);
3888
+								closedir(dd);
3889
+								return -1;
3890
+							}
3883 3891
 						}
3884 3892
 					fclose(fin);
3885 3893
 
... ...
@@ -562,7 +562,7 @@ int cli_gentempfd(const char *dir, char **name, int *fd)
562 562
 /* Function: unlink
563 563
         unlink() with error checking
564 564
 */
565
-int cli_unlink(const char *pathname)
565
+void cli_unlink(const char *pathname)
566 566
 {
567 567
 	if (unlink(pathname)) cli_warnmsg("cli_unlink: failure - %s\n", strerror(errno));
568 568
 }
... ...
@@ -704,12 +704,7 @@ int cli_rmdirs(const char *dirname)
704 704
 				    }
705 705
 				}
706 706
 			    } else
707
-				if(cli_unlink(path) < 0) {
708
-				    cli_warnmsg("cli_rmdirs: Couldn't remove %s: %s\n", path, strerror(errno));
709
-				    free(path);
710
-				    closedir(dd);
711
-				    return -1;
712
-				}
707
+				cli_unlink(path); 
713 708
 			}
714 709
 			free(path);
715 710
 		    }
... ...
@@ -233,7 +233,7 @@ int cli_rmdirs(const char *dirname);
233 233
 unsigned char *cli_md5digest(int desc);
234 234
 char *cli_md5stream(FILE *fs, unsigned char *digcpy);
235 235
 char *cli_md5file(const char *filename);
236
-int cli_unlink(const char *pathname);
236
+void cli_unlink(const char *pathname);
237 237
 int cli_readn(int fd, void *buff, unsigned int count);
238 238
 int cli_writen(int fd, const void *buff, unsigned int count);
239 239
 char *cli_gentemp(const char *dir);