...
|
...
|
@@ -1212,8 +1212,7 @@ int cli_scanpe(cli_ctx *ctx)
|
1212
|
1212
|
exe_sections[i].ursz = EC32(section_hdr[i].SizeOfRawData);
|
1213
|
1213
|
|
1214
|
1214
|
if (exe_sections[i].rsz) { /* Don't bother with virtual only sections */
|
1215
|
|
- if (!CLI_ISCONTAINED(0, fsize, exe_sections[i].uraw, exe_sections[i].ursz)
|
1216
|
|
- || exe_sections[i].raw >= fsize) {
|
|
1215
|
+ if (exe_sections[i].raw >= fsize || exe_sections[i].uraw > fsize) {
|
1217
|
1216
|
cli_dbgmsg("Broken PE file - Section %d starts or exists beyond the end of file (Offset@ %lu, Total filesize %lu)\n", i, (unsigned long)exe_sections[i].raw, (unsigned long)fsize);
|
1218
|
1217
|
if (nsections == 1) {
|
1219
|
1218
|
free(section_hdr);
|
...
|
...
|
@@ -1237,11 +1236,17 @@ int cli_scanpe(cli_ctx *ctx)
|
1237
|
1237
|
rescan=1;
|
1238
|
1238
|
break;
|
1239
|
1239
|
}
|
|
1240
|
+
|
|
1241
|
+ if (!CLI_ISCONTAINED(0, (uint32_t) fsize, exe_sections[i].raw, exe_sections[i].rsz))
|
|
1242
|
+ exe_sections[i].rsz = fsize - exe_sections[i].raw;
|
|
1243
|
+
|
|
1244
|
+ if (!CLI_ISCONTAINED(0, fsize, exe_sections[i].uraw, exe_sections[i].ursz))
|
|
1245
|
+ exe_sections[i].ursz = fsize - exe_sections[i].uraw;
|
1240
|
1246
|
}
|
1241
|
1247
|
}
|
1242
|
1248
|
}
|
1243
|
1249
|
|
1244
|
|
- for(i = 0; i < nsections; i++) {
|
|
1250
|
+ for(i = 0; i < nsections; i++) {
|
1245
|
1251
|
strncpy(sname, (char *) section_hdr[i].Name, 8);
|
1246
|
1252
|
sname[8] = 0;
|
1247
|
1253
|
|
...
|
...
|
@@ -1258,9 +1263,6 @@ int cli_scanpe(cli_ctx *ctx)
|
1258
|
1258
|
if (!exe_sections[i].vsz && exe_sections[i].rsz)
|
1259
|
1259
|
exe_sections[i].vsz=PESALIGN(exe_sections[i].ursz, valign);
|
1260
|
1260
|
|
1261
|
|
- if (exe_sections[i].rsz && fsize>exe_sections[i].raw && !CLI_ISCONTAINED(0, (uint32_t) fsize, exe_sections[i].raw, exe_sections[i].rsz))
|
1262
|
|
- exe_sections[i].rsz = fsize - exe_sections[i].raw;
|
1263
|
|
-
|
1264
|
1261
|
cli_dbgmsg("Section %d\n", i);
|
1265
|
1262
|
cli_dbgmsg("Section name: %s\n", sname);
|
1266
|
1263
|
cli_dbgmsg("Section data (from headers - in memory)\n");
|