summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorJens-Heiner Rechtien <hr@openoffice.org>2009-07-28 09:21:19 +0000
committerJens-Heiner Rechtien <hr@openoffice.org>2009-07-28 09:21:19 +0000
commit9c4ae699b5b91fa193b4ccf0bf29a3c1e69676b4 (patch)
treec585390f0f58983e4ffaf6a48fa6ccdbf14e912c /tools
parent801268f69c46e8b5f7f25af82806460c9f7b77f2 (diff)
CWS-TOOLING: integrate CWS fwk112
2009-07-17 08:54:15 +0200 cd r274075 : #i102094# MinGW needs additional path info for linking 2009-07-13 15:09:07 +0200 cd r273938 : #i102094# Add special part for MinGW linking to imagehlp.lib 2009-07-10 08:05:14 +0200 cd r273871 : #i102094# Use size_t for constant values to fix warnings 2009-07-09 13:45:27 +0200 cd r273859 : #i102094# MinGW needs include malloc.h for function alloca 2009-07-09 12:37:39 +0200 cd r273856 : #i102094# Fix problem with signed/unsigned comparision warning 2009-06-19 11:34:40 +0200 cd r273154 : #i102094# Added comment for future maintenance 2009-06-19 11:34:11 +0200 cd r273153 : #i102094# Added comment for future maintenance 2009-06-16 17:25:03 +0200 cd r273032 : #i102094# Extend md5.cxx to detect Windows PE images and ignore PE header date+time/checksum to have the same MD5 checksum 2009-06-16 17:22:47 +0200 cd r273031 : #i102094# Added rebase custom action 2009-06-16 17:01:12 +0200 cd r273030 : #i102094# Use rebaseoo.exe instead of rebase.exe to prevent clash with build tool 2009-06-16 17:00:34 +0200 cd r273029 : #i102094# Execute rebase custom action for administrative installations 2009-06-16 16:59:11 +0200 cd r273028 : #i102094# Small changes for rebaseoo/rebasegui tools 2009-06-16 16:58:29 +0200 cd r273027 : i102094# Deliver rebase tool as rebaseoo.exe as build env already use a rebase.exe 2009-06-16 16:57:15 +0200 cd r273026 : i102094# Crash reporter should not use PE header date+time/checksum data for MD5 checksum 2009-05-29 17:03:26 +0200 cd r272474 : #i102094# Fix wrong deliver statement 2009-05-29 14:55:35 +0200 cd r272459 : #i102904# Make executables more robust. Add error message if installation cannot be found 2009-05-28 17:41:07 +0200 cd r272422 : CWS-TOOLING: rebase CWS fwk112 to trunk@272291 (milestone: DEV300:m49) 2009-05-28 17:31:27 +0200 cd r272421 : #i10000# Resolve conflict on merge 2009-05-28 15:32:09 +0200 cd r272409 : #i102094# Added resource and localization files for rebasegui tool 2009-05-27 13:56:33 +0200 cd r272341 : #i102094# Added new command line tool to rebase libraries to a default virtual load address. Additional GUI tool to check the state of an installation 2009-05-26 10:49:20 +0200 cd r272285 : #i102094# New command line tool to rebase libraries to a default virtual load address 2009-05-26 10:40:02 +0200 cd r272282 : #i102094# New command line tool to rebase libraries to a default virtual load address 2009-05-26 08:57:24 +0200 cd r272280 : #i102094# Fixed wrong variable usage 2009-05-26 08:41:29 +0200 cd r272278 : #i102094# New command line tool to rebase libraries to a default virtual load address 2009-05-20 16:47:24 +0200 cd r272141 : #102094# Added missing include statement for debug build 2009-05-20 15:39:21 +0200 is r272136 : #102094# rebase to default value in installation 2009-05-20 15:38:38 +0200 is r272135 : #102094# rebase to default value in installation 2009-05-20 15:37:45 +0200 is r272134 : #102094# rebase to default value in installation
Diffstat (limited to 'tools')
-rw-r--r--tools/bootstrp/md5.cxx64
1 files changed, 63 insertions, 1 deletions
diff --git a/tools/bootstrp/md5.cxx b/tools/bootstrp/md5.cxx
index bca89725fac2..a234f278cc9d 100644
--- a/tools/bootstrp/md5.cxx
+++ b/tools/bootstrp/md5.cxx
@@ -44,8 +44,62 @@
#define FILE_OPEN_READ "r"
#endif
+// Extended calc_md5_checksum to recognize Windows executables and libraries. To
+// create the same md5 checksum for a (code/data) identical file it ignores a different
+// date and header checksum. Please see crashrep/source/win32/soreport.cpp
+// where the same method is also used. The crash reporter uses the MD5
+// checksums to transfer them to the crash database. You have to make sure that both
+// methods use the same algorithm otherwise there could be problems with stack reports.
+
+void normalize_pe_image(sal_uInt8* buffer, size_t nBufferSize)
+{
+ const int OFFSET_PE_OFFSET = 0x3c;
+ const int OFFSET_COFF_TIMEDATESTAMP = 4;
+ const int PE_SIGNATURE_SIZE = 4;
+ const int COFFHEADER_SIZE = 20;
+ const int OFFSET_PE_OPTIONALHEADER_CHECKSUM = 64;
+
+ // Check the header part of the file buffer
+ if (buffer[0] == sal_uInt8('M') && buffer[1] == sal_uInt8('Z'))
+ {
+ unsigned long PEHeaderOffset = (long)buffer[OFFSET_PE_OFFSET];
+ if (PEHeaderOffset < nBufferSize-4)
+ {
+ if ( buffer[PEHeaderOffset+0] == sal_uInt8('P') &&
+ buffer[PEHeaderOffset+1] == sal_uInt8('E') &&
+ buffer[PEHeaderOffset+2] == 0 &&
+ buffer[PEHeaderOffset+3] == 0 )
+ {
+ PEHeaderOffset += PE_SIGNATURE_SIZE;
+ if (PEHeaderOffset+OFFSET_COFF_TIMEDATESTAMP < nBufferSize-4)
+ {
+ // Set timedatestamp and checksum fields to a normalized
+ // value to enforce the same MD5 checksum for identical
+ // Windows executables/libraries.
+ buffer[PEHeaderOffset+OFFSET_COFF_TIMEDATESTAMP+0] = 0;
+ buffer[PEHeaderOffset+OFFSET_COFF_TIMEDATESTAMP+1] = 0;
+ buffer[PEHeaderOffset+OFFSET_COFF_TIMEDATESTAMP+2] = 0;
+ buffer[PEHeaderOffset+OFFSET_COFF_TIMEDATESTAMP+3] = 0;
+ }
+
+ if (PEHeaderOffset+COFFHEADER_SIZE+OFFSET_PE_OPTIONALHEADER_CHECKSUM < nBufferSize-4)
+ {
+ // Set checksum to a normalized value
+ buffer[PEHeaderOffset+COFFHEADER_SIZE+OFFSET_PE_OPTIONALHEADER_CHECKSUM] = 0;
+ buffer[PEHeaderOffset+COFFHEADER_SIZE+OFFSET_PE_OPTIONALHEADER_CHECKSUM+1] = 0;
+ buffer[PEHeaderOffset+COFFHEADER_SIZE+OFFSET_PE_OPTIONALHEADER_CHECKSUM+2] = 0;
+ buffer[PEHeaderOffset+COFFHEADER_SIZE+OFFSET_PE_OPTIONALHEADER_CHECKSUM+3] = 0;
+ }
+ }
+ }
+ }
+}
+
rtlDigestError calc_md5_checksum( const char *filename, ByteString &aChecksum )
{
+ const size_t BUFFER_SIZE = 0x1000;
+ const size_t MINIMAL_SIZE = 512;
+
sal_uInt8 checksum[RTL_DIGEST_LENGTH_MD5];
rtlDigestError error = rtl_Digest_E_None;
@@ -58,11 +112,19 @@ rtlDigestError calc_md5_checksum( const char *filename, ByteString &aChecksum )
if ( digest )
{
size_t nBytesRead;
- sal_uInt8 buffer[0x1000];
+ sal_uInt8 buffer[BUFFER_SIZE];
+ bool bHeader(true);
while ( rtl_Digest_E_None == error &&
0 != (nBytesRead = fread( buffer, 1, sizeof(buffer), fp )) )
{
+ if (bHeader)
+ {
+ bHeader = false;
+ if (nBytesRead >= MINIMAL_SIZE && buffer[0] == sal_uInt8('M') && buffer[1] == sal_uInt8('Z') )
+ normalize_pe_image(buffer, nBytesRead);
+ }
+
error = rtl_digest_updateMD5( digest, buffer, nBytesRead );
}