git-svn-id: file:///var/lib/svn/clamav-devel/trunk/clamav-devel@1388 77e5149b-7576-45b1-b177-96237e5ba77b
Tomasz Kojm authored on 2005/03/16 01:42:07... | ... |
@@ -267,6 +267,16 @@ int cli_scanpe(int desc, const char **virname, long int *scanned, const struct c |
267 | 267 |
} |
268 | 268 |
|
269 | 269 |
nsections = EC16(file_hdr.NumberOfSections); |
270 |
+ if(nsections < 1) { |
|
271 |
+ if(DETECT_BROKEN) { |
|
272 |
+ if(virname) |
|
273 |
+ *virname = "Broken.Executable"; |
|
274 |
+ return CL_VIRUS; |
|
275 |
+ } |
|
276 |
+ cli_warnmsg("PE file contains no sections\n"); |
|
277 |
+ return CL_CLEAN; |
|
278 |
+ } |
|
279 |
+ |
|
270 | 280 |
cli_dbgmsg("NumberOfSections: %d\n", nsections); |
271 | 281 |
|
272 | 282 |
timestamp = (time_t) EC32(file_hdr.TimeDateStamp); |
... | ... |
@@ -1167,7 +1177,7 @@ int cli_scanpe(int desc, const char **virname, long int *scanned, const struct c |
1167 | 1167 |
} |
1168 | 1168 |
|
1169 | 1169 |
if(buff[0] != '\xb8' || cli_readint32(buff + 1) != EC32(section_hdr[nsections - 1].VirtualAddress) + EC32(optional_hdr.ImageBase)) { |
1170 |
- if(buff[0] != '\xb8' || cli_readint32(buff + 1) != EC32(section_hdr[nsections - 2].VirtualAddress) + EC32(optional_hdr.ImageBase)) |
|
1170 |
+ if(buff[0] != '\xb8' || (nsections > 1 && cli_readint32(buff + 1) != EC32(section_hdr[nsections - 2].VirtualAddress) + EC32(optional_hdr.ImageBase))) |
|
1171 | 1171 |
found = 0; |
1172 | 1172 |
else |
1173 | 1173 |
found = 1; |