0.96
aCaB 16 years ago
parent 94f8946c5a
commit a0c381973b
  1. 4
      ChangeLog
  2. 9
      libclamav/fmap.c
  3. 1
      libclamav/fmap.h
  4. 6
      libclamav/matcher.c

@ -1,3 +1,7 @@
Tue May 4 18:47:31 CEST 2010 (acab)
------------------------------------
* libclamav: no ERROR on void mapping (bb#1968)
Tue May 4 16:47:57 CEST 2010 (tk)
----------------------------------
* libclamav/matcher-ac.c: fix counting of subsig matches (bb#2001)

@ -92,12 +92,18 @@ pthread_mutex_t fmap_mutex = PTHREAD_MUTEX_INITIALIZER;
ssize_t pread(int fd, void *buf, size_t count, off_t offset);
fmap_t *fmap(int fd, off_t offset, size_t len) {
int unused;
return fmap_check_empty(fd, offset, len, &unused);
}
fmap_t *fmap_check_empty(int fd, off_t offset, size_t len, int *empty) {
unsigned int pages, mapsz, hdrsz;
unsigned short dumb = 1;
int pgsz = cli_getpagesize();
struct stat st;
fmap_t *m;
*empty = 0;
if(fstat(fd, &st)) {
cli_warnmsg("fmap: fstat failed\n");
return NULL;
@ -108,7 +114,8 @@ fmap_t *fmap(int fd, off_t offset, size_t len) {
}
if(!len) len = st.st_size - offset; /* bound checked later */
if(!len) {
cli_warnmsg("fmap: attempted void mapping\n");
cli_dbgmsg("fmap: attempted void mapping\n");
*empty = 1;
return NULL;
}
if(!CLI_ISCONTAINED(0, st.st_size, offset, len)) {

@ -48,6 +48,7 @@ typedef struct {
} fmap_t;
fmap_t *fmap(int fd, off_t offset, size_t len);
fmap_t *fmap_check_empty(int fd, off_t offset, size_t len, int *empty);
void funmap(fmap_t *m);
void *fmap_need_off(fmap_t *m, size_t at, size_t len);
void *fmap_need_off_once(fmap_t *m, size_t at, size_t len);

@ -402,15 +402,17 @@ static int matchicon(cli_ctx *ctx, const char *grp1, const char *grp2)
int cli_scandesc(int desc, cli_ctx *ctx, cli_file_t ftype, uint8_t ftonly, struct cli_matched_type **ftoffset, unsigned int acmode)
{
int ret = CL_EMEM;
int ret = CL_EMEM, empty;
fmap_t *map = *ctx->fmap;
if((*ctx->fmap = fmap(desc, 0, 0))) {
if((*ctx->fmap = fmap_check_empty(desc, 0, 0, &empty))) {
ret = cli_fmap_scandesc(ctx, ftype, ftonly, ftoffset, acmode, NULL);
map->dont_cache_flag = (*ctx->fmap)->dont_cache_flag;
funmap(*ctx->fmap);
}
*ctx->fmap = map;
if(empty)
return CL_CLEAN;
return ret;
}

Loading…
Cancel
Save