... | ... |
@@ -48,8 +48,8 @@ |
48 | 48 |
*/ |
49 | 49 |
|
50 | 50 |
/* FIXME: tune this stuff */ |
51 |
-#define UNPAGE_THRSHLD_HI 1*1024*1024 |
|
52 |
-#define UNPAGE_THRSHLD_LO 4*1024*1024 |
|
51 |
+#define UNPAGE_THRSHLD_LO 1*1024*1024 |
|
52 |
+#define UNPAGE_THRSHLD_HI 4*1024*1024 |
|
53 | 53 |
|
54 | 54 |
struct F_MAP { |
55 | 55 |
int fd; |
... | ... |
@@ -165,7 +165,7 @@ static void fmap_aging(struct F_MAP *m) { |
165 | 165 |
if(avail * m->pgsz > UNPAGE_THRSHLD_HI ) { |
166 | 166 |
/* if we've got more unpageable pages than we need, we pick the oldest */ |
167 | 167 |
fmap_qsel(m, freeme, 0, avail - 1); |
168 |
- avail = UNPAGE_THRSHLD_HI % m->pgsz; |
|
168 |
+ avail = UNPAGE_THRSHLD_HI / m->pgsz; |
|
169 | 169 |
} |
170 | 170 |
for(i=0; i<avail; i++) { |
171 | 171 |
char *pptr = (char *)m + i * m->pgsz + m->hdrsz; |
... | ... |
@@ -214,7 +214,7 @@ static int fmap_readpage(struct F_MAP *m, unsigned int page, int lock) { |
214 | 214 |
|
215 | 215 |
/* page is not already paged */ |
216 | 216 |
pptr = (char *)m + page * m->pgsz + m->hdrsz; |
217 |
- if(page == m->pages - 1) |
|
217 |
+ if((page == m->pages - 1) && (m->len % m->pgsz)) |
|
218 | 218 |
readsz = m->len % m->pgsz; |
219 | 219 |
else |
220 | 220 |
readsz = m->pgsz; |
... | ... |
@@ -913,7 +913,7 @@ int cli_ole2_extract(int fd, const char *dirname, cli_ctx *ctx, struct uniq **vb |
913 | 913 |
hdr.m_length = statbuf.st_size; |
914 | 914 |
hdr.map = fmap(fd, 0, hdr.m_length); |
915 | 915 |
if (hdr.map) { |
916 |
- void *phdr = fmap_need_off(hdr.map, 0, hdr_size); |
|
916 |
+ void *phdr = fmap_need_off_once(hdr.map, 0, hdr_size); |
|
917 | 917 |
if(phdr) { |
918 | 918 |
cli_dbgmsg("mmap'ed file\n"); |
919 | 919 |
memcpy(&hdr, phdr, hdr_size); |
... | ... |
@@ -936,7 +936,7 @@ int cli_ole2_extract(int fd, const char *dirname, cli_ctx *ctx, struct uniq **vb |
936 | 936 |
} |
937 | 937 |
#endif |
938 | 938 |
} |
939 |
- |
|
939 |
+ |
|
940 | 940 |
hdr.minor_version = ole2_endian_convert_16(hdr.minor_version); |
941 | 941 |
hdr.dll_version = ole2_endian_convert_16(hdr.dll_version); |
942 | 942 |
hdr.byte_order = ole2_endian_convert_16(hdr.byte_order); |