git-svn: trunk@3075
Tomasz Kojm authored on 2007/05/29 21:58:01... | ... |
@@ -1,3 +1,7 @@ |
1 |
+Tue May 29 14:22:32 CEST 2007 (tk) |
|
2 |
+---------------------------------- |
|
3 |
+ * libclamav/scanners.c: move cli_scannulsft() to nsis/nulsft.c (bb#523) |
|
4 |
+ |
|
1 | 5 |
Tue May 29 09:17:41 BST 2007 (trog) |
2 | 6 |
----------------------------------- |
3 | 7 |
* libclamav/unrar/unrar.c: Bug #521, #368 |
... | ... |
@@ -36,6 +36,8 @@ |
36 | 36 |
#include "LZMADecode.h" |
37 | 37 |
#include "nsis_zlib.h" |
38 | 38 |
|
39 |
+extern short cli_leavetemps_flag; |
|
40 |
+ |
|
39 | 41 |
#ifndef O_BINARY |
40 | 42 |
#define O_BINARY 0 |
41 | 43 |
#endif |
... | ... |
@@ -449,3 +451,64 @@ void cli_nsis_free(struct nsis_st *n) { |
449 | 449 |
nsis_shutdown(n); |
450 | 450 |
if (n->solid && n->freeme) free(n->freeme); |
451 | 451 |
} |
452 |
+ |
|
453 |
+int cli_scannulsft(int desc, cli_ctx *ctx, off_t offset) { |
|
454 |
+ int ret; |
|
455 |
+ struct nsis_st nsist; |
|
456 |
+ |
|
457 |
+ cli_dbgmsg("in scannulsft()\n"); |
|
458 |
+ if(ctx->limits && ctx->limits->maxreclevel && ctx->arec >= ctx->limits->maxreclevel) { |
|
459 |
+ cli_dbgmsg("Archive recursion limit exceeded (arec == %u).\n", ctx->arec+1); |
|
460 |
+ return CL_EMAXREC; |
|
461 |
+ } |
|
462 |
+ |
|
463 |
+ memset(&nsist, 0, sizeof(struct nsis_st)); |
|
464 |
+ |
|
465 |
+ nsist.ifd = desc; |
|
466 |
+ nsist.off = offset; |
|
467 |
+ nsist.dir = cli_gentemp(NULL); |
|
468 |
+ if(mkdir(nsist.dir, 0700)) { |
|
469 |
+ cli_dbgmsg("NSIS: Can't create temporary directory %s\n", nsist.dir); |
|
470 |
+ free(nsist.dir); |
|
471 |
+ return CL_ETMPDIR; |
|
472 |
+ } |
|
473 |
+ |
|
474 |
+ ctx->arec++; |
|
475 |
+ |
|
476 |
+ do { |
|
477 |
+ ret = cli_nsis_unpack(&nsist, ctx); |
|
478 |
+ if(ret != CL_SUCCESS) { |
|
479 |
+ if(ret == CL_EMAXSIZE) { |
|
480 |
+ if(BLOCKMAX) { |
|
481 |
+ *ctx->virname = "NSIS.ExceededFileSize"; |
|
482 |
+ ret=CL_VIRUS; |
|
483 |
+ } else { |
|
484 |
+ ret = nsist.solid ? CL_BREAK : CL_SUCCESS; |
|
485 |
+ } |
|
486 |
+ } |
|
487 |
+ } else { |
|
488 |
+ cli_dbgmsg("NSIS: Successully extracted file #%u\n", nsist.fno); |
|
489 |
+ lseek(nsist.ofd, 0, SEEK_SET); |
|
490 |
+ if(nsist.fno == 1) |
|
491 |
+ ret=cli_scandesc(nsist.ofd, ctx, 0, 0, 0, NULL); |
|
492 |
+ else |
|
493 |
+ ret=cli_magic_scandesc(nsist.ofd, ctx); |
|
494 |
+ close(nsist.ofd); |
|
495 |
+ if(!cli_leavetemps_flag) |
|
496 |
+ unlink(nsist.ofn); |
|
497 |
+ } |
|
498 |
+ } while(ret == CL_SUCCESS); |
|
499 |
+ |
|
500 |
+ if(ret == CL_BREAK) |
|
501 |
+ ret = CL_CLEAN; |
|
502 |
+ |
|
503 |
+ cli_nsis_free(&nsist); |
|
504 |
+ |
|
505 |
+ if(!cli_leavetemps_flag) |
|
506 |
+ cli_rmdirs(nsist.dir); |
|
507 |
+ |
|
508 |
+ free(nsist.dir); |
|
509 |
+ |
|
510 |
+ ctx->arec--; |
|
511 |
+ return ret; |
|
512 |
+} |
... | ... |
@@ -85,7 +85,6 @@ extern short cli_leavetemps_flag; |
85 | 85 |
#include "mspack.h" |
86 | 86 |
#include "cab.h" |
87 | 87 |
#include "rtf.h" |
88 |
-#include "nsis/nulsft.h" |
|
89 | 88 |
|
90 | 89 |
#ifdef HAVE_ZLIB_H |
91 | 90 |
#include <zlib.h> |
... | ... |
@@ -103,6 +102,7 @@ extern short cli_leavetemps_flag; |
103 | 103 |
|
104 | 104 |
#define MAX_MAIL_RECURSION 15 |
105 | 105 |
|
106 |
+int cli_scannulsft(int desc, cli_ctx *ctx, off_t offset); /* FIXME */ |
|
106 | 107 |
static int cli_scanfile(const char *filename, cli_ctx *ctx); |
107 | 108 |
|
108 | 109 |
static int cli_unrar_scanmetadata(int desc, rar_metadata_t *metadata, cli_ctx *ctx, unsigned int files, uint32_t* sfx_check) |
... | ... |
@@ -800,67 +800,6 @@ static int cli_scanbzip(int desc, cli_ctx *ctx) |
800 | 800 |
} |
801 | 801 |
#endif |
802 | 802 |
|
803 |
-static int cli_scannulsft(int desc, cli_ctx *ctx, off_t offset) { |
|
804 |
- int ret; |
|
805 |
- struct nsis_st nsist; |
|
806 |
- |
|
807 |
- cli_dbgmsg("in scannulsft()\n"); |
|
808 |
- if(ctx->limits && ctx->limits->maxreclevel && ctx->arec >= ctx->limits->maxreclevel) { |
|
809 |
- cli_dbgmsg("Archive recursion limit exceeded (arec == %u).\n", ctx->arec+1); |
|
810 |
- return CL_EMAXREC; |
|
811 |
- } |
|
812 |
- |
|
813 |
- memset(&nsist, 0, sizeof(struct nsis_st)); |
|
814 |
- |
|
815 |
- nsist.ifd = desc; |
|
816 |
- nsist.off = offset; |
|
817 |
- nsist.dir = cli_gentemp(NULL); |
|
818 |
- if(mkdir(nsist.dir, 0700)) { |
|
819 |
- cli_dbgmsg("NSIS: Can't create temporary directory %s\n", nsist.dir); |
|
820 |
- free(nsist.dir); |
|
821 |
- return CL_ETMPDIR; |
|
822 |
- } |
|
823 |
- |
|
824 |
- ctx->arec++; |
|
825 |
- |
|
826 |
- do { |
|
827 |
- ret = cli_nsis_unpack(&nsist, ctx); |
|
828 |
- if(ret != CL_SUCCESS) { |
|
829 |
- if(ret == CL_EMAXSIZE) { |
|
830 |
- if(BLOCKMAX) { |
|
831 |
- *ctx->virname = "NSIS.ExceededFileSize"; |
|
832 |
- ret=CL_VIRUS; |
|
833 |
- } else { |
|
834 |
- ret = nsist.solid ? CL_BREAK : CL_SUCCESS; |
|
835 |
- } |
|
836 |
- } |
|
837 |
- } else { |
|
838 |
- cli_dbgmsg("NSIS: Successully extracted file #%u\n", nsist.fno); |
|
839 |
- lseek(nsist.ofd, 0, SEEK_SET); |
|
840 |
- if(nsist.fno == 1) |
|
841 |
- ret=cli_scandesc(nsist.ofd, ctx, 0, 0, 0, NULL); |
|
842 |
- else |
|
843 |
- ret=cli_magic_scandesc(nsist.ofd, ctx); |
|
844 |
- close(nsist.ofd); |
|
845 |
- if(!cli_leavetemps_flag) |
|
846 |
- unlink(nsist.ofn); |
|
847 |
- } |
|
848 |
- } while(ret == CL_SUCCESS); |
|
849 |
- |
|
850 |
- if(ret == CL_BREAK) |
|
851 |
- ret = CL_CLEAN; |
|
852 |
- |
|
853 |
- cli_nsis_free(&nsist); |
|
854 |
- |
|
855 |
- if(!cli_leavetemps_flag) |
|
856 |
- cli_rmdirs(nsist.dir); |
|
857 |
- |
|
858 |
- free(nsist.dir); |
|
859 |
- |
|
860 |
- ctx->arec--; |
|
861 |
- return ret; |
|
862 |
-} |
|
863 |
- |
|
864 | 803 |
static int cli_scanszdd(int desc, cli_ctx *ctx) |
865 | 804 |
{ |
866 | 805 |
int fd, ret = CL_CLEAN, dcpy; |