Dmitry Timoshkov : winedump:
Add a sanity check before dumping long format library export.
Alexandre Julliard
julliard at wine.codeweavers.com
Mon Feb 5 07:45:02 CST 2007
Module: wine
Branch: master
Commit: 6d62ef657de15216c7ee23d722fa3b1f02ec7dcb
URL: http://source.winehq.org/git/wine.git/?a=commit;h=6d62ef657de15216c7ee23d722fa3b1f02ec7dcb
Author: Dmitry Timoshkov <dmitry at codeweavers.com>
Date: Mon Feb 5 14:19:44 2007 +0800
winedump: Add a sanity check before dumping long format library export.
---
tools/winedump/lib.c | 12 ++++++++----
1 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/tools/winedump/lib.c b/tools/winedump/lib.c
index a7f8367..155a6fa 100644
--- a/tools/winedump/lib.c
+++ b/tools/winedump/lib.c
@@ -183,6 +183,9 @@ void lib_dump(void)
cur_file_pos += sizeof(IMAGE_ARCHIVE_MEMBER_HEADER);
+ size = strtoul((const char *)iamh->Size, NULL, 10);
+ size = (size + 1) & ~1; /* align to an even address */
+
/* FIXME: only import library contents with the short format are
* recognized.
*/
@@ -193,6 +196,7 @@ void lib_dump(void)
}
else if (strncmp((const char *)iamh->Name, IMAGE_ARCHIVE_LINKER_MEMBER, sizeof(iamh->Name)))
{
+ long expected_size;
const IMAGE_FILE_HEADER *fh = (const IMAGE_FILE_HEADER *)ioh;
if (globals.do_dumpheader)
@@ -204,12 +208,12 @@ void lib_dump(void)
dump_optional_header(oh, fh->SizeOfOptionalHeader);
}
}
- dump_long_import(fh, (const IMAGE_SECTION_HEADER *)((const char *)fh + sizeof(*fh) + fh->SizeOfOptionalHeader), fh->NumberOfSections);
+ /* Sanity check */
+ expected_size = sizeof(*fh) + fh->SizeOfOptionalHeader + fh->NumberOfSections * sizeof(IMAGE_SECTION_HEADER);
+ if (size > expected_size)
+ dump_long_import(fh, (const IMAGE_SECTION_HEADER *)((const char *)fh + sizeof(*fh) + fh->SizeOfOptionalHeader), fh->NumberOfSections);
}
- size = strtoul((const char *)iamh->Size, NULL, 10);
- size = (size + 1) & ~1; /* align to an even address */
-
cur_file_pos += size;
}
}
More information about the wine-cvs
mailing list