git-svn: trunk@2398
Tomasz Kojm authored on 2006/10/16 08:54:33... | ... |
@@ -1,3 +1,8 @@ |
1 |
+Mon Oct 16 01:52:58 CEST 2006 (tk) |
|
2 |
+---------------------------------- |
|
3 |
+ * libclamav/rebuildpe.c: fix possible heap overflow [IDEF1597] |
|
4 |
+ * libclamav/chmunpack.c: fix possible crash [IDEF1736] |
|
5 |
+ |
|
1 | 6 |
Mon Oct 16 01:39:35 CEST 2006 (tk) |
2 | 7 |
---------------------------------- |
3 | 8 |
* freshclam: increase default ConnectTimeout to 30 secs |
... | ... |
@@ -452,6 +452,11 @@ static int read_chunk_entries(unsigned char *chunk, uint32_t chunk_len, |
452 | 452 |
file_e->next = NULL; |
453 | 453 |
|
454 | 454 |
name_len = read_enc_int(¤t, end); |
455 |
+ if (((current + name_len) > end) || ((current + name_len) < chunk)) { |
|
456 |
+ cli_dbgmsg("Bad CHM name_len detected\n"); |
|
457 |
+ free(file_e); |
|
458 |
+ return FALSE; |
|
459 |
+ } |
|
455 | 460 |
if (name_len > 0xFFFFFF) { |
456 | 461 |
cli_dbgmsg("CHM file name too long: %llu\n", name_len); |
457 | 462 |
file_e->name = (unsigned char *) strdup("truncated"); |
... | ... |
@@ -122,9 +122,16 @@ char *rebuildpe(char *buffer, struct SECTION *sections, int sects, uint32_t base |
122 | 122 |
char *pefile=NULL, *curpe; |
123 | 123 |
struct IMAGE_PE_HEADER *fakepe; |
124 | 124 |
|
125 |
+ |
|
126 |
+ if(sects > 90) |
|
127 |
+ return NULL; |
|
128 |
+ |
|
125 | 129 |
for (i=0; i < sects; i++) |
126 | 130 |
datasize+=sections[i].rsz; |
127 | 131 |
|
132 |
+ if(datasize > CLI_MAX_ALLOCATION) |
|
133 |
+ return NULL; |
|
134 |
+ |
|
128 | 135 |
rawbase = 0x148+0x80+0x28*sects; |
129 | 136 |
if((pefile = (char *) cli_malloc(rawbase+datasize))) { |
130 | 137 |
memcpy(pefile, HEADERS, 0x148); |
... | ... |
@@ -150,6 +150,7 @@ static int jpeg_check_photoshop(int fd) |
150 | 150 |
{ |
151 | 151 |
int retval; |
152 | 152 |
unsigned char buffer[14]; |
153 |
+ off_t old, new; |
|
153 | 154 |
|
154 | 155 |
if (cli_readn(fd, buffer, 14) != 14) { |
155 | 156 |
return 0; |
... | ... |
@@ -161,7 +162,11 @@ static int jpeg_check_photoshop(int fd) |
161 | 161 |
|
162 | 162 |
cli_dbgmsg("Found Photoshop segment\n"); |
163 | 163 |
do { |
164 |
+ old = lseek(fd, 0, SEEK_CUR); |
|
164 | 165 |
retval = jpeg_check_photoshop_8bim(fd); |
166 |
+ new = lseek(fd, 0, SEEK_CUR); |
|
167 |
+ if(new <= old) |
|
168 |
+ break; |
|
165 | 169 |
} while (retval == 0); |
166 | 170 |
|
167 | 171 |
if (retval == -1) { |