Browse code

bb#384 - unlink

git-svn: trunk@3747

aCaB authored on 2008/04/02 20:13:16
Showing 14 changed files
... ...
@@ -1,3 +1,7 @@
1
+Wed Apr  2 12:30:06 CEST 2008 (acab)
2
+------------------------------------
3
+  * libclamav: check return codes from syscalls (bb#384) - unlink
4
+
1 5
 Thu Mar 27 20:16:07 EET 2008 (edwin)
2 6
 ------------------------------------
3 7
   * test: add test file for RTF (bb #902)
... ...
@@ -374,11 +374,11 @@ static int ea05(int desc, cli_ctx *ctx, char *tmpd) {
374 374
     lseek(i, 0, SEEK_SET);
375 375
     if(cli_magic_scandesc(i, ctx) == CL_VIRUS) {
376 376
       close(i);
377
-      if(!cli_leavetemps_flag) unlink(tempfile);
377
+      if(!cli_leavetemps_flag) cli_unlink(tempfile);
378 378
       return CL_VIRUS;
379 379
     }
380 380
     close(i);
381
-    if(!cli_leavetemps_flag) unlink(tempfile);
381
+    if(!cli_leavetemps_flag) cli_unlink(tempfile);
382 382
   }
383 383
   return ret;
384 384
 }
... ...
@@ -882,11 +882,11 @@ static int ea06(int desc, cli_ctx *ctx, char *tmpd) {
882 882
     lseek(i, 0, SEEK_SET);
883 883
     if(cli_magic_scandesc(i, ctx) == CL_VIRUS) {
884 884
       close(i);
885
-      if(!cli_leavetemps_flag) unlink(tempfile);
885
+      if(!cli_leavetemps_flag) cli_unlink(tempfile);
886 886
       return CL_VIRUS;
887 887
     }
888 888
     close(i);
889
-    if(!cli_leavetemps_flag) unlink(tempfile);
889
+    if(!cli_leavetemps_flag) cli_unlink(tempfile);
890 890
   }
891 891
   return ret;
892 892
 }
... ...
@@ -437,7 +437,7 @@ fileblobDestructiveDestroy(fileblob *fb)
437 437
 	if(fb->fp && fb->fullname) {
438 438
 		fclose(fb->fp);
439 439
 		cli_dbgmsg("fileblobDestructiveDestroy: %s\n", fb->fullname);
440
-		if(unlink(fb->fullname) < 0)
440
+		if(cli_unlink(fb->fullname) < 0)
441 441
 			cli_warnmsg("fileblobDestructiveDestroy: Can't delete file %s\n", fb->fullname);
442 442
 		free(fb->fullname);
443 443
 		fb->fp = NULL;
... ...
@@ -466,7 +466,7 @@ fileblobDestroy(fileblob *fb)
466 466
 			cli_dbgmsg("fileblobDestroy: %s\n", fb->fullname);
467 467
 			if(!fb->isNotEmpty) {
468 468
 				cli_dbgmsg("fileblobDestroy: not saving empty file\n");
469
-				if(unlink(fb->fullname) < 0)
469
+				if(cli_unlink(fb->fullname) < 0)
470 470
 					cli_warnmsg("fileblobDestroy: Can't delete empty file %s\n", fb->fullname);
471 471
 			}
472 472
 		}
... ...
@@ -765,7 +765,7 @@ static int chm_decompress_stream(int fd, chm_metadata_t *metadata, const char *d
765 765
 	lzx_free(stream);
766 766
 	
767 767
 	/* Delete the file */
768
-	unlink(filename);
768
+	cli_unlink(filename);
769 769
 	retval = tmpfd;
770 770
 	
771 771
 abort:
... ...
@@ -1240,7 +1240,7 @@ cli_parse_mbox(const char *dir, int desc, cli_ctx *ctx)
1240 1240
 		/* empty message */
1241 1241
 		fclose(fd);
1242 1242
 #ifdef	SAVE_TMP
1243
-		unlink(tmpfilename);
1243
+		cli_unlink(tmpfilename);
1244 1244
 #endif
1245 1245
 		return CL_CLEAN;
1246 1246
 	}
... ...
@@ -1258,7 +1258,7 @@ cli_parse_mbox(const char *dir, int desc, cli_ctx *ctx)
1258 1258
 #endif
1259 1259
 			fclose(fd);
1260 1260
 #ifdef	SAVE_TMP
1261
-			unlink(tmpfilename);
1261
+			cli_unlink(tmpfilename);
1262 1262
 #endif
1263 1263
 			return CL_EMEM;
1264 1264
 		}
... ...
@@ -1319,7 +1319,7 @@ cli_parse_mbox(const char *dir, int desc, cli_ctx *ctx)
1319 1319
 			signal(SIGSEGV, segv);
1320 1320
 #endif
1321 1321
 #ifdef	SAVE_TMP
1322
-			unlink(tmpfilename);
1322
+			cli_unlink(tmpfilename);
1323 1323
 #endif
1324 1324
 			return CL_EMEM;
1325 1325
 		}
... ...
@@ -1477,7 +1477,7 @@ cli_parse_mbox(const char *dir, int desc, cli_ctx *ctx)
1477 1477
 #endif
1478 1478
 
1479 1479
 #ifdef	SAVE_TMP
1480
-	unlink(tmpfilename);
1480
+	cli_unlink(tmpfilename);
1481 1481
 #endif
1482 1482
 	return retcode;
1483 1483
 }
... ...
@@ -3874,7 +3874,7 @@ rfc1341(message *m, const char *dir)
3874 3874
 						if(stat(fullname, &statb) < 0)
3875 3875
 							continue;
3876 3876
 						if(now - statb.st_mtime > (time_t)(7 * 24 * 3600))
3877
-							if(unlink(fullname) >= 0)
3877
+							if(cli_unlink(fullname) >= 0)
3878 3878
 								cli_dbgmsg("removed old RFC1341 file %s\n", fullname);
3879 3879
 						continue;
3880 3880
 					}
... ...
@@ -3883,7 +3883,7 @@ rfc1341(message *m, const char *dir)
3883 3883
 					if(fin == NULL) {
3884 3884
 						cli_errmsg("Can't open '%s' for reading", fullname);
3885 3885
 						fclose(fout);
3886
-						unlink(outname);
3886
+						cli_unlink(outname);
3887 3887
 						free(id);
3888 3888
 						free(number);
3889 3889
 						closedir(dd);
... ...
@@ -3906,9 +3906,9 @@ rfc1341(message *m, const char *dir)
3906 3906
 						}
3907 3907
 					fclose(fin);
3908 3908
 
3909
-					/* don't unlink if leave temps */
3909
+					/* don't cli_unlink if leave temps */
3910 3910
 					if(!cli_leavetemps_flag)
3911
-						unlink(fullname);
3911
+						cli_unlink(fullname);
3912 3912
 					break;
3913 3913
 				}
3914 3914
 				rewinddir(dd);
... ...
@@ -4411,7 +4411,7 @@ getURL(struct arg *arg)
4411 4411
 					if(location) {
4412 4412
 						char *end;
4413 4413
 
4414
-						unlink(fout);
4414
+						cli_unlink(fout);
4415 4415
 						location += 11;
4416 4416
 						end = location;
4417 4417
 						while(*end && (*end != '\n'))
... ...
@@ -560,6 +560,14 @@ int cli_gentempfd(const char *dir, char **name, int *fd)
560 560
 }
561 561
 #endif
562 562
 
563
+/* Function: unlink
564
+        unlink() with error checking
565
+*/
566
+int cli_unlink(const char *pathname)
567
+{
568
+	if (unlink(pathname)) cli_warnmsg("cli_unlink: failure - %s\n", strerror(errno));
569
+}
570
+
563 571
 #ifdef	C_WINDOWS
564 572
 /*
565 573
  * Windows doesn't allow you to delete a directory while it is still open
... ...
@@ -585,7 +593,7 @@ cli_rmdirs(const char *name)
585 585
     }
586 586
 
587 587
     if(!S_ISDIR(statb.st_mode)) {
588
-	if(unlink(name) < 0) {
588
+	if(cli_unlink(name) < 0) {
589 589
 	    cli_warnmsg("cli_rmdirs: Can't remove %s: %s\n", name, strerror(errno));
590 590
 	    return -1;
591 591
 	}
... ...
@@ -697,7 +705,7 @@ int cli_rmdirs(const char *dirname)
697 697
 				    }
698 698
 				}
699 699
 			    } else
700
-				if(unlink(path) < 0) {
700
+				if(cli_unlink(path) < 0) {
701 701
 				    cli_warnmsg("cli_rmdirs: Couldn't remove %s: %s\n", path, strerror(errno));
702 702
 				    free(path);
703 703
 				    closedir(dd);
... ...
@@ -809,6 +817,7 @@ int cli_filecopy(const char *src, const char *dest)
809 809
     return close(d);
810 810
 }
811 811
 
812
+
812 813
 /* Implement a generic bitset, trog@clamav.net */
813 814
 
814 815
 #define BITS_PER_CHAR (8)
... ...
@@ -234,6 +234,7 @@ int cli_rmdirs(const char *dirname);
234 234
 unsigned char *cli_md5digest(int desc);
235 235
 char *cli_md5stream(FILE *fs, unsigned char *digcpy);
236 236
 char *cli_md5file(const char *filename);
237
+int cli_unlink(const char *pathname);
237 238
 int cli_readn(int fd, void *buff, unsigned int count);
238 239
 int cli_writen(int fd, const void *buff, unsigned int count);
239 240
 char *cli_gentemp(const char *dir);
... ...
@@ -393,7 +393,7 @@ cli_pdf(const char *dir, int desc, cli_ctx *ctx)
393 393
 		if(streamend <= streamstart) {
394 394
 			close(fout);
395 395
 			cli_dbgmsg("cli_pdf: Empty stream\n");
396
-			unlink(fullname);
396
+			cli_unlink(fullname);
397 397
 			continue;
398 398
 		}
399 399
 		calculated_streamlen = (int)(streamend - streamstart);
... ...
@@ -419,7 +419,7 @@ cli_pdf(const char *dir, int desc, cli_ctx *ctx)
419 419
 
420 420
 			if(ret != CL_CLEAN) {
421 421
 				close(fout);
422
-				unlink(fullname);
422
+				cli_unlink(fullname);
423 423
 				continue;
424 424
 			}
425 425
 
... ...
@@ -427,7 +427,7 @@ cli_pdf(const char *dir, int desc, cli_ctx *ctx)
427 427
 
428 428
 			if(tmpbuf == NULL) {
429 429
 				close(fout);
430
-				unlink(fullname);
430
+				cli_unlink(fullname);
431 431
 				continue;
432 432
 			}
433 433
 
... ...
@@ -436,7 +436,7 @@ cli_pdf(const char *dir, int desc, cli_ctx *ctx)
436 436
 			if(ret == -1) {
437 437
 				free(tmpbuf);
438 438
 				close(fout);
439
-				unlink(fullname);
439
+				cli_unlink(fullname);
440 440
 				continue;
441 441
 			}
442 442
 			if(ret) {
... ...
@@ -448,7 +448,7 @@ cli_pdf(const char *dir, int desc, cli_ctx *ctx)
448 448
 				if(t == NULL) {
449 449
 					free(tmpbuf);
450 450
 					close(fout);
451
-					unlink(fullname);
451
+					cli_unlink(fullname);
452 452
 					continue;
453 453
 				}
454 454
 				tmpbuf = t;
... ...
@@ -490,7 +490,7 @@ cli_pdf(const char *dir, int desc, cli_ctx *ctx)
490 490
 				if(tableFind(md5table, md5str) >= 0) {
491 491
 					cli_dbgmsg("cli_pdf: not scanning duplicate embedded file '%s'\n", fullname);
492 492
 					close(fout);
493
-					unlink(fullname);
493
+					cli_unlink(fullname);
494 494
 					continue;
495 495
 				} else
496 496
 					tableInsert(md5table, md5str, 1);
... ...
@@ -500,7 +500,7 @@ cli_pdf(const char *dir, int desc, cli_ctx *ctx)
500 500
 			rc = cli_magic_scandesc(fout, ctx);
501 501
 		}
502 502
 		close(fout);
503
-		if(!cli_leavetemps_flag) unlink(fullname);
503
+		if(!cli_leavetemps_flag) cli_unlink(fullname);
504 504
 		if(rc != CL_CLEAN) break;
505 505
 	}
506 506
 
... ...
@@ -650,7 +650,7 @@ flatedecode(unsigned char *buf, off_t len, int fout, cli_ctx *ctx)
650 650
 	}
651 651
 			
652 652
 #ifdef	SAVE_TMP
653
-	unlink(tmpfilename);
653
+	cli_unlink(tmpfilename);
654 654
 #endif
655 655
 	inflateEnd(&stream);
656 656
 	return CL_CLEAN;
... ...
@@ -99,13 +99,13 @@ if((ndesc = open(tempfile, O_RDWR|O_CREAT|O_TRUNC|O_BINARY, S_IRWXU)) < 0) { \
99 99
     return CL_EIO; \
100 100
 }
101 101
 
102
-#define CLI_TMPUNLK() if(!cli_leavetemps_flag) unlink(tempfile)
102
+#define CLI_TMPUNLK() if(!cli_leavetemps_flag) cli_unlink(tempfile)
103 103
 
104 104
 #define FSGCASE(NAME,FREESEC) \
105 105
     case 0: /* Unpacked and NOT rebuilt */ \
106 106
 	cli_dbgmsg(NAME": Successfully decompressed\n"); \
107 107
 	close(ndesc); \
108
-	unlink(tempfile); \
108
+	cli_unlink(tempfile); \
109 109
 	free(tempfile); \
110 110
 	FREESEC; \
111 111
 	found = 0; \
... ...
@@ -116,7 +116,7 @@ if((ndesc = open(tempfile, O_RDWR|O_CREAT|O_TRUNC|O_BINARY, S_IRWXU)) < 0) { \
116 116
     case 2: \
117 117
 	free(spinned); \
118 118
 	close(ndesc); \
119
-	unlink(tempfile); \
119
+	cli_unlink(tempfile); \
120 120
 	cli_dbgmsg("PESpin: Size exceeded\n"); \
121 121
 	free(tempfile); \
122 122
 	break; \
... ...
@@ -148,7 +148,7 @@ FSGSTUFF; \
148 148
     default: \
149 149
 	cli_dbgmsg(NAME": Unpacking failed\n"); \
150 150
 	close(ndesc); \
151
-	unlink(tempfile); \
151
+	cli_unlink(tempfile); \
152 152
 	cli_multifree FREEME; \
153 153
         free(tempfile); \
154 154
     }
... ...
@@ -235,7 +235,7 @@ static int cli_ddump(int desc, int offset, int size, const char *file) {
235 235
 		cli_dbgmsg("Can't write to file\n");
236 236
 		lseek(desc, pos, SEEK_SET);
237 237
 		close(ndesc);
238
-		unlink(file);
238
+		cli_unlink(file);
239 239
 		return -1;
240 240
 	    }
241 241
 	    break;
... ...
@@ -244,7 +244,7 @@ static int cli_ddump(int desc, int offset, int size, const char *file) {
244 244
 		cli_dbgmsg("Can't write to file\n");
245 245
 		lseek(desc, pos, SEEK_SET);
246 246
 		close(ndesc);
247
-		unlink(file);
247
+		cli_unlink(file);
248 248
 		return -1;
249 249
 	    }
250 250
 	}
... ...
@@ -248,7 +248,7 @@ static int decode_and_scan(struct rtf_object_data* data, cli_ctx* ctx)
248 248
 	data->fd = -1;
249 249
 	if(data->name) {
250 250
 		if(!cli_leavetemps_flag)
251
-			unlink(data->name);
251
+			cli_unlink(data->name);
252 252
 		free(data->name);
253 253
 		data->name = NULL;
254 254
 	}
... ...
@@ -326,7 +326,7 @@ static int cli_scanrar(int desc, cli_ctx *ctx, off_t sfx_offset, uint32_t *sfx_c
326 326
 	    rc = cli_magic_scandesc(rar_state.ofd,ctx);
327 327
 	    close(rar_state.ofd);
328 328
 	    if(!cli_leavetemps_flag) 
329
-		unlink(rar_state.filename);
329
+		cli_unlink(rar_state.filename);
330 330
 	    if(rc == CL_VIRUS ) {
331 331
 		cli_dbgmsg("RAR: infected with %s\n",*ctx->virname);
332 332
 		ret = CL_VIRUS;
... ...
@@ -468,7 +468,7 @@ static int cli_scangzip(int desc, cli_ctx *ctx)
468 468
 	gzclose(gd);
469 469
 	close(fd);
470 470
 	if(!cli_leavetemps_flag)
471
-	    unlink(tmpname);
471
+	    cli_unlink(tmpname);
472 472
 	free(tmpname);	
473 473
 	return CL_EMEM;
474 474
     }
... ...
@@ -483,7 +483,7 @@ static int cli_scangzip(int desc, cli_ctx *ctx)
483 483
 	    cli_dbgmsg("GZip: Can't write to file.\n");
484 484
 	    close(fd);
485 485
 	    if(!cli_leavetemps_flag)
486
-		unlink(tmpname);
486
+		cli_unlink(tmpname);
487 487
 	    free(tmpname);	
488 488
 	    gzclose(gd);
489 489
 	    free(buff);
... ...
@@ -497,7 +497,7 @@ static int cli_scangzip(int desc, cli_ctx *ctx)
497 497
     if(ret == CL_VIRUS) {
498 498
 	close(fd);
499 499
 	if(!cli_leavetemps_flag)
500
-	    unlink(tmpname);
500
+	    cli_unlink(tmpname);
501 501
 	free(tmpname);	
502 502
 	return ret;
503 503
     }
... ...
@@ -507,13 +507,13 @@ static int cli_scangzip(int desc, cli_ctx *ctx)
507 507
 	cli_dbgmsg("GZip: Infected with %s\n", *ctx->virname);
508 508
 	close(fd);
509 509
 	if(!cli_leavetemps_flag)
510
-	    unlink(tmpname);
510
+	    cli_unlink(tmpname);
511 511
 	free(tmpname);	
512 512
 	return CL_VIRUS;
513 513
     }
514 514
     close(fd);
515 515
     if(!cli_leavetemps_flag)
516
-	unlink(tmpname);
516
+	cli_unlink(tmpname);
517 517
     free(tmpname);	
518 518
 
519 519
     return ret;
... ...
@@ -564,7 +564,7 @@ static int cli_scanbzip(int desc, cli_ctx *ctx)
564 564
 	cli_dbgmsg("Bzip: Unable to malloc %u bytes.\n", FILEBUFF);
565 565
 	close(fd);
566 566
 	if(!cli_leavetemps_flag)
567
-	    unlink(tmpname);
567
+	    cli_unlink(tmpname);
568 568
 	free(tmpname);	
569 569
 	fclose(fs);
570 570
 	BZ2_bzReadClose(&bzerror, bfd);
... ...
@@ -582,7 +582,7 @@ static int cli_scanbzip(int desc, cli_ctx *ctx)
582 582
 	    BZ2_bzReadClose(&bzerror, bfd);
583 583
 	    close(fd);
584 584
 	    if(!cli_leavetemps_flag)
585
-		unlink(tmpname);
585
+		cli_unlink(tmpname);
586 586
 	    free(tmpname);	
587 587
 	    free(buff);
588 588
 	    fclose(fs);
... ...
@@ -596,7 +596,7 @@ static int cli_scanbzip(int desc, cli_ctx *ctx)
596 596
     if(ret == CL_VIRUS) {
597 597
 	close(fd);
598 598
 	if(!cli_leavetemps_flag)
599
-	    unlink(tmpname);
599
+	    cli_unlink(tmpname);
600 600
 	free(tmpname);	
601 601
 	fclose(fs);
602 602
 	return ret;
... ...
@@ -608,7 +608,7 @@ static int cli_scanbzip(int desc, cli_ctx *ctx)
608 608
     }
609 609
     close(fd);
610 610
     if(!cli_leavetemps_flag)
611
-	unlink(tmpname);
611
+	cli_unlink(tmpname);
612 612
     free(tmpname);	
613 613
     fclose(fs);
614 614
 
... ...
@@ -635,7 +635,7 @@ static int cli_scanszdd(int desc, cli_ctx *ctx)
635 635
     if(ret != CL_SUCCESS) { /* CL_VIRUS or some error */
636 636
 	close(ofd);
637 637
 	if(!cli_leavetemps_flag)
638
-	    unlink(tmpname);
638
+	    cli_unlink(tmpname);
639 639
 	free(tmpname);	
640 640
 	return ret;
641 641
     }
... ...
@@ -645,7 +645,7 @@ static int cli_scanszdd(int desc, cli_ctx *ctx)
645 645
     ret = cli_magic_scandesc(ofd, ctx);
646 646
     close(ofd);
647 647
     if(!cli_leavetemps_flag)
648
-	unlink(tmpname);
648
+	cli_unlink(tmpname);
649 649
     free(tmpname);	
650 650
 
651 651
     return ret;
... ...
@@ -682,7 +682,7 @@ static int cli_scanmscab(int desc, cli_ctx *ctx, off_t sfx_offset)
682 682
 	    ret = cli_scanfile(tempname, ctx);
683 683
 
684 684
 	if(!cli_leavetemps_flag)
685
-	    unlink(tempname);
685
+	    cli_unlink(tempname);
686 686
 	free(tempname);
687 687
 	if(ret == CL_VIRUS)
688 688
 	    break;
... ...
@@ -1030,7 +1030,7 @@ static int cli_scanhtml_utf16(int desc, cli_ctx *ctx)
1030 1030
 	    if(write(fd, decoded, strlen(decoded)) == -1) {
1031 1031
 		cli_errmsg("cli_scanhtml_utf16: Can't write to file %s\n", tempname);
1032 1032
 		free(decoded);
1033
-		unlink(tempname);
1033
+		cli_unlink(tempname);
1034 1034
 		free(tempname);
1035 1035
 		close(fd);
1036 1036
 		return CL_EIO;
... ...
@@ -1044,7 +1044,7 @@ static int cli_scanhtml_utf16(int desc, cli_ctx *ctx)
1044 1044
     close(fd);
1045 1045
 
1046 1046
     if(!cli_leavetemps_flag)
1047
-	unlink(tempname);
1047
+	cli_unlink(tempname);
1048 1048
     else
1049 1049
 	cli_dbgmsg("cli_scanhtml_utf16: Decoded HTML data saved in %s\n", tempname);
1050 1050
     free(tempname);
... ...
@@ -1344,7 +1344,7 @@ static int cli_scancryptff(int desc, cli_ctx *ctx)
1344 1344
     if(cli_leavetemps_flag)
1345 1345
 	cli_dbgmsg("CryptFF: Decompressed data saved in %s\n", tempfile);
1346 1346
     else
1347
-	unlink(tempfile);
1347
+	cli_unlink(tempfile);
1348 1348
 
1349 1349
     free(tempfile);
1350 1350
     return ret;
... ...
@@ -1490,7 +1490,7 @@ static int cli_scanembpe(int desc, cli_ctx *ctx)
1490 1490
 	    cli_dbgmsg("cli_scanembpe: Can't write to temporary file\n");
1491 1491
 	    close(fd);
1492 1492
 	    if(!cli_leavetemps_flag)
1493
-		unlink(tmpname);
1493
+		cli_unlink(tmpname);
1494 1494
 	    free(tmpname);	
1495 1495
 	    return CL_EIO;
1496 1496
 	}
... ...
@@ -1502,7 +1502,7 @@ static int cli_scanembpe(int desc, cli_ctx *ctx)
1502 1502
 	cli_dbgmsg("cli_scanembpe: Infected with %s\n", *ctx->virname);
1503 1503
 	close(fd);
1504 1504
 	if(!cli_leavetemps_flag)
1505
-	    unlink(tmpname);
1505
+	    cli_unlink(tmpname);
1506 1506
 	free(tmpname);	
1507 1507
 	return CL_VIRUS;
1508 1508
     }
... ...
@@ -1510,7 +1510,7 @@ static int cli_scanembpe(int desc, cli_ctx *ctx)
1510 1510
 
1511 1511
     close(fd);
1512 1512
     if(!cli_leavetemps_flag)
1513
-	unlink(tmpname);
1513
+	cli_unlink(tmpname);
1514 1514
     free(tmpname);
1515 1515
 
1516 1516
     /* intentionally ignore possible errors from cli_magic_scandesc */
... ...
@@ -96,7 +96,7 @@ cli_untar(const char *dir, int desc, unsigned int posix, cli_ctx *ctx)
96 96
 				ret = cli_magic_scandesc(fout, ctx);
97 97
 				close(fout);
98 98
 				if (!cli_leavetemps_flag)
99
-					unlink(fullname);
99
+					cli_unlink(fullname);
100 100
 				if (ret==CL_VIRUS)
101 101
 					return CL_VIRUS;
102 102
 				fout = -1;
... ...
@@ -221,7 +221,7 @@ cli_untar(const char *dir, int desc, unsigned int posix, cli_ctx *ctx)
221 221
 		ret = cli_magic_scandesc(fout, ctx);
222 222
 		close(fout);
223 223
 		if (!cli_leavetemps_flag)
224
-			unlink(fullname);
224
+			cli_unlink(fullname);
225 225
 		if (ret==CL_VIRUS)
226 226
 			return CL_VIRUS;
227 227
 	}
... ...
@@ -283,13 +283,13 @@ static int unz(uint8_t *src, uint32_t csize, uint32_t usize, uint16_t method, ui
283 283
     lseek(of, 0, SEEK_SET);
284 284
     ret = cli_magic_scandesc(of, ctx);
285 285
     close(of);
286
-    if(!cli_leavetemps_flag) unlink(tempfile);
286
+    if(!cli_leavetemps_flag) cli_unlink(tempfile);
287 287
     if(!tmpd) free(tempfile);
288 288
     return ret;
289 289
   }
290 290
 
291 291
   close(of);
292
-  if(!cli_leavetemps_flag) unlink(tempfile);
292
+  if(!cli_leavetemps_flag) cli_unlink(tempfile);
293 293
   if(!tmpd) free(tempfile);
294 294
   cli_dbgmsg("cli_unzip: extraction failed\n");
295 295
   return ret;
... ...
@@ -714,14 +714,14 @@ ppt_unlzw(const char *dir, int fd, uint32_t length)
714 714
 
715 715
 	if(cli_readn(fd, inbuff, stream.avail_in) != (int)stream.avail_in) {
716 716
 		close(ofd);
717
-		unlink(fullname);
717
+		cli_unlink(fullname);
718 718
 		return FALSE;
719 719
 	}
720 720
 	length -= stream.avail_in;
721 721
 
722 722
 	if(inflateInit(&stream) != Z_OK) {
723 723
 		close(ofd);
724
-		unlink(fullname);
724
+		cli_unlink(fullname);
725 725
 		cli_warnmsg("ppt_unlzw: inflateInit failed\n");
726 726
 		return FALSE;
727 727
 	}