... | ... |
@@ -1,3 +1,8 @@ |
1 |
+Wed Jun 8 14:57:40 CEST 2011 (acab) |
|
2 |
+------------------------------------ |
|
3 |
+ * libclamav/nsis, libclamav/chmunpack.[ch], libclamav/scanners.c: |
|
4 |
+ don't remap in NSIS, CHM (bb#2838) |
|
5 |
+ |
|
1 | 6 |
Thu May 26 14:17:52 CEST 2011 (acab) |
2 | 7 |
------------------------------------ |
3 | 8 |
* libclamav/matcher-hash.c: in hm_sort don't swap an item with itself (bb#2818) |
... | ... |
@@ -486,7 +486,7 @@ static int read_sys_reset_table(chm_metadata_t *metadata, lzx_reset_table_t *lzx |
486 | 486 |
/* This section interfaces to the mspack files. As such, this is a */ |
487 | 487 |
/* little bit dirty compared to my usual code */ |
488 | 488 |
|
489 |
-static int chm_decompress_stream(int fd, chm_metadata_t *metadata, const char *dirname, cli_ctx *ctx) |
|
489 |
+static int chm_decompress_stream(chm_metadata_t *metadata, const char *dirname, cli_ctx *ctx) |
|
490 | 490 |
{ |
491 | 491 |
lzx_content_t lzx_content; |
492 | 492 |
lzx_reset_table_t lzx_reset_table; |
... | ... |
@@ -555,13 +555,13 @@ static int chm_decompress_stream(int fd, chm_metadata_t *metadata, const char *d |
555 | 555 |
length &= -lzx_control.reset_interval; |
556 | 556 |
|
557 | 557 |
cli_dbgmsg("Compressed offset: %lu\n", (unsigned long int) lzx_content.offset); |
558 |
- if ((uint64_t) lseek(fd, lzx_content.offset, SEEK_SET) != lzx_content.offset) { |
|
558 |
+ if ((uint64_t) lseek(metadata->map->fd, lzx_content.offset, SEEK_SET) != lzx_content.offset) { |
|
559 | 559 |
goto abort; |
560 | 560 |
} |
561 | 561 |
|
562 | 562 |
memset(&file, 0, sizeof(struct cab_file)); |
563 | 563 |
file.max_size = ctx->engine->maxfilesize; |
564 |
- stream = lzx_init(fd, tmpfd, window_bits, |
|
564 |
+ stream = lzx_init(metadata->map->fd, tmpfd, window_bits, |
|
565 | 565 |
lzx_control.reset_interval / LZX_FRAME_SIZE, |
566 | 566 |
4096, length, &file, NULL); |
567 | 567 |
if (!stream) { |
... | ... |
@@ -608,7 +608,6 @@ void cli_chm_close(chm_metadata_t *metadata) |
608 | 608 |
if (metadata->ufd >= 0) { |
609 | 609 |
close(metadata->ufd); |
610 | 610 |
} |
611 |
- funmap(metadata->map); |
|
612 | 611 |
} |
613 | 612 |
|
614 | 613 |
int cli_chm_extract_file(char *dirname, chm_metadata_t *metadata, cli_ctx *ctx) |
... | ... |
@@ -659,7 +658,7 @@ int cli_chm_prepare_file(chm_metadata_t *metadata) |
659 | 659 |
return retval; |
660 | 660 |
} |
661 | 661 |
|
662 |
-int cli_chm_open(int fd, const char *dirname, chm_metadata_t *metadata, cli_ctx *ctx) |
|
662 |
+int cli_chm_open(const char *dirname, chm_metadata_t *metadata, cli_ctx *ctx) |
|
663 | 663 |
{ |
664 | 664 |
struct stat statbuf; |
665 | 665 |
int retval; |
... | ... |
@@ -670,20 +669,10 @@ int cli_chm_open(int fd, const char *dirname, chm_metadata_t *metadata, cli_ctx |
670 | 670 |
return retval; |
671 | 671 |
} |
672 | 672 |
|
673 |
- if (fstat(fd, &statbuf) == 0) { |
|
674 |
- if (statbuf.st_size < CHM_ITSF_MIN_LEN) { |
|
675 |
- return CL_ESTAT; |
|
676 |
- } |
|
677 |
- metadata->m_length = statbuf.st_size; |
|
678 |
- metadata->map = fmap(fd, 0, metadata->m_length); |
|
679 |
- if (!metadata->map) { |
|
680 |
- return CL_EMAP; |
|
681 |
- } |
|
682 |
- } else { |
|
683 |
- char err[128]; |
|
684 |
- cli_warnmsg("fstat() failed: %s\n", cli_strerror(errno, err, sizeof(err))); |
|
685 |
- return CL_ESTAT; |
|
686 |
- } |
|
673 |
+ metadata->map = *ctx->fmap; |
|
674 |
+ if(metadata->map->len < CHM_ITSF_MIN_LEN) |
|
675 |
+ return CL_ESTAT; |
|
676 |
+ metadata->m_length = metadata->map->len; |
|
687 | 677 |
|
688 | 678 |
if (!itsf_read_header(metadata)) { |
689 | 679 |
goto abort; |
... | ... |
@@ -730,7 +719,7 @@ int cli_chm_open(int fd, const char *dirname, chm_metadata_t *metadata, cli_ctx |
730 | 730 |
goto abort; |
731 | 731 |
} |
732 | 732 |
|
733 |
- metadata->ufd = chm_decompress_stream(fd, metadata, dirname, ctx); |
|
733 |
+ metadata->ufd = chm_decompress_stream(metadata, dirname, ctx); |
|
734 | 734 |
if (metadata->ufd == -1) { |
735 | 735 |
goto abort; |
736 | 736 |
} |
... | ... |
@@ -743,6 +732,5 @@ int cli_chm_open(int fd, const char *dirname, chm_metadata_t *metadata, cli_ctx |
743 | 743 |
return CL_SUCCESS; |
744 | 744 |
|
745 | 745 |
abort: |
746 |
- funmap(metadata->map); |
|
747 | 746 |
return CL_EFORMAT; |
748 | 747 |
} |
... | ... |
@@ -115,7 +115,7 @@ typedef struct chm_metadata_tag { |
115 | 115 |
uint16_t chunk_entries; |
116 | 116 |
} chm_metadata_t; |
117 | 117 |
|
118 |
-int cli_chm_open(int fd, const char *dirname, chm_metadata_t *metadata, cli_ctx *ctx); |
|
118 |
+int cli_chm_open(const char *dirname, chm_metadata_t *metadata, cli_ctx *ctx); |
|
119 | 119 |
int cli_chm_prepare_file(chm_metadata_t *metadata); |
120 | 120 |
int cli_chm_extract_file(char *dirname, chm_metadata_t *metadata, cli_ctx *ctx); |
121 | 121 |
void cli_chm_close(chm_metadata_t *metadata); |
... | ... |
@@ -1265,7 +1265,7 @@ static int cli_scantar(int desc, cli_ctx *ctx, unsigned int posix) |
1265 | 1265 |
return ret; |
1266 | 1266 |
} |
1267 | 1267 |
|
1268 |
-static int cli_scanmschm(int desc, cli_ctx *ctx) |
|
1268 |
+static int cli_scanmschm(cli_ctx *ctx) |
|
1269 | 1269 |
{ |
1270 | 1270 |
int ret = CL_CLEAN, rc; |
1271 | 1271 |
chm_metadata_t metadata; |
... | ... |
@@ -1283,7 +1283,7 @@ static int cli_scanmschm(int desc, cli_ctx *ctx) |
1283 | 1283 |
return CL_ETMPDIR; |
1284 | 1284 |
} |
1285 | 1285 |
|
1286 |
- ret = cli_chm_open(desc, dir, &metadata, ctx); |
|
1286 |
+ ret = cli_chm_open(dir, &metadata, ctx); |
|
1287 | 1287 |
if (ret != CL_SUCCESS) { |
1288 | 1288 |
if(!ctx->engine->keeptmp) |
1289 | 1289 |
cli_rmdirs(dir); |
... | ... |
@@ -2362,7 +2362,7 @@ static int magic_scandesc(int desc, cli_ctx *ctx, cli_file_t type) |
2362 | 2362 |
ctx->container_type = CL_TYPE_MSCHM; |
2363 | 2363 |
ctx->container_size = sb.st_size; |
2364 | 2364 |
if(SCAN_ARCHIVE && (DCONF_ARCH & ARCH_CONF_CHM)) |
2365 |
- ret = cli_scanmschm(desc, ctx); |
|
2365 |
+ ret = cli_scanmschm(ctx); |
|
2366 | 2366 |
break; |
2367 | 2367 |
|
2368 | 2368 |
case CL_TYPE_MSOLE2: |