Bug 599475 - Fix crash reporting on MacOS 10.5 (Leopard) by making breakpad use it's internal implementation of MD5 instead of one randomly picked from libnss or libcrypto which isn't loading properly. r=ted a=blocking-beta8+

This commit is contained in:
Benjamin Smedberg 2010-11-20 16:58:47 -05:00
parent a09905d6a5
commit 53205f2ce6
3 changed files with 14 additions and 16 deletions

View File

@ -53,19 +53,19 @@ bool FileID::FileIdentifier(unsigned char identifier[16]) {
if (fd == -1) if (fd == -1)
return false; return false;
MD5_CTX md5; MD5Context md5;
MD5_Init(&md5); MD5Init(&md5);
// Read 4k x 2 bytes at a time. This is faster than just 4k bytes, but // Read 4k x 2 bytes at a time. This is faster than just 4k bytes, but
// doesn't seem to be an unreasonable size for the stack. // doesn't seem to be an unreasonable size for the stack.
unsigned char buffer[4096 * 2]; unsigned char buffer[4096 * 2];
size_t buffer_size = sizeof(buffer); size_t buffer_size = sizeof(buffer);
while ((buffer_size = read(fd, buffer, buffer_size) > 0)) { while ((buffer_size = read(fd, buffer, buffer_size) > 0)) {
MD5_Update(&md5, buffer, buffer_size); MD5Update(&md5, buffer, buffer_size);
} }
close(fd); close(fd);
MD5_Final(identifier, &md5); MD5Final(identifier, &md5);
return true; return true;
} }

View File

@ -37,7 +37,6 @@ extern "C" { // necessary for Leopard
#include <fcntl.h> #include <fcntl.h>
#include <mach-o/loader.h> #include <mach-o/loader.h>
#include <mach-o/swap.h> #include <mach-o/swap.h>
#include <openssl/md5.h>
#include <openssl/sha.h> #include <openssl/sha.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
@ -47,6 +46,7 @@ extern "C" { // necessary for Leopard
#include <unistd.h> #include <unistd.h>
} }
#include "common/md5.h"
#include "common/mac/macho_id.h" #include "common/mac/macho_id.h"
#include "common/mac/macho_walker.h" #include "common/mac/macho_walker.h"
#include "common/mac/macho_utilities.h" #include "common/mac/macho_utilities.h"
@ -117,7 +117,7 @@ void MachoID::UpdateCRC(unsigned char *bytes, size_t size) {
} }
void MachoID::UpdateMD5(unsigned char *bytes, size_t size) { void MachoID::UpdateMD5(unsigned char *bytes, size_t size) {
MD5_Update(&md5_context_, bytes, size); MD5Update(&md5_context_, bytes, size);
} }
void MachoID::UpdateSHA1(unsigned char *bytes, size_t size) { void MachoID::UpdateSHA1(unsigned char *bytes, size_t size) {
@ -225,17 +225,14 @@ bool MachoID::MD5(int cpu_type, unsigned char identifier[16]) {
MachoWalker walker(path_, WalkerCB, this); MachoWalker walker(path_, WalkerCB, this);
update_function_ = &MachoID::UpdateMD5; update_function_ = &MachoID::UpdateMD5;
if (MD5_Init(&md5_context_)) { MD5Init(&md5_context_);
if (!walker.WalkHeader(cpu_type)) if (!walker.WalkHeader(cpu_type))
return false; return false;
MD5_Final(identifier, &md5_context_); MD5Final(identifier, &md5_context_);
return true; return true;
} }
return false;
}
bool MachoID::SHA1(int cpu_type, unsigned char identifier[16]) { bool MachoID::SHA1(int cpu_type, unsigned char identifier[16]) {
MachoWalker walker(path_, WalkerCB, this); MachoWalker walker(path_, WalkerCB, this);
update_function_ = &MachoID::UpdateSHA1; update_function_ = &MachoID::UpdateSHA1;

View File

@ -36,9 +36,10 @@
#include <limits.h> #include <limits.h>
#include <mach-o/loader.h> #include <mach-o/loader.h>
#include <openssl/md5.h>
#include <openssl/sha.h> #include <openssl/sha.h>
#include "common/md5.h"
namespace MacFileUtilities { namespace MacFileUtilities {
class MachoWalker; class MachoWalker;
@ -110,7 +111,7 @@ class MachoID {
uint32_t crc_; uint32_t crc_;
// The MD5 context // The MD5 context
MD5_CTX md5_context_; MD5Context md5_context_;
// The SHA1 context // The SHA1 context
SHA_CTX sha1_context_; SHA_CTX sha1_context_;