diff options
author | Jens-Heiner Rechtien <hr@openoffice.org> | 2009-07-28 09:21:19 +0000 |
---|---|---|
committer | Jens-Heiner Rechtien <hr@openoffice.org> | 2009-07-28 09:21:19 +0000 |
commit | 90ed76b32d11ac91a9920105a81c1544718fb193 (patch) | |
tree | 3db58914a49da1ef7dbaaeb37ad4da78fd70a0ff /crashrep | |
parent | 76e947292e66f56e46b09cffd9b76db794185c8e (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 'crashrep')
-rwxr-xr-x | crashrep/source/win32/soreport.cpp | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/crashrep/source/win32/soreport.cpp b/crashrep/source/win32/soreport.cpp index 4c897f76e0b5..043ad62b0051 100755 --- a/crashrep/source/win32/soreport.cpp +++ b/crashrep/source/win32/soreport.cpp @@ -1564,8 +1564,60 @@ static void repatch_soffice_exe( void *pBuffer, size_t nBufSize ) } while ( !bPatched && nBufSize ); } +// Normalize executable/library images to prevent different MD5 checksums due +// to a different PE header date/checksum (this doesn't affect the code/data +// sections of a executable/library. Please see tools/source/bootstrp/md5.cxx +// where the same method is also used. The tool so_checksum creates the MD5 +// checksums during build time. You have to make sure that both methods use the +// same algorithm otherwise there could be problems with stack reports. +static 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] == 'M' && buffer[1] == 'Z') + { + unsigned long PEHeaderOffset = (long)buffer[OFFSET_PE_OFFSET]; + if (PEHeaderOffset < nBufferSize-4) + { + if ( buffer[PEHeaderOffset] == 'P' && + buffer[PEHeaderOffset+1] == '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; + 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; + } + } + } + } +} + static sal_uInt32 calc_md5_checksum( const char *filename, sal_uInt8 *pChecksum, sal_uInt32 nChecksumLen ) { + const int MINIMAL_FILESIZE = 512; + sal_uInt32 nBytesProcessed = 0; FILE *fp = fopen( filename, "rb" ); @@ -1585,6 +1637,8 @@ static sal_uInt32 calc_md5_checksum( const char *filename, sal_uInt8 *pChecksum { if ( 0 == stricmp( GetFileName(filename).c_str(), "soffice.bin" ) ) repatch_soffice_exe( pBuffer, nBytesRead ); + else if ( nFileSize > MINIMAL_FILESIZE ) + normalize_pe_image( pBuffer, nBytesRead ); rtlDigestError error = rtl_digest_MD5 ( pBuffer, nBytesRead, |