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+
--- a/toolkit/crashreporter/google-breakpad/src/common/mac/file_id.cc
+++ b/toolkit/crashreporter/google-breakpad/src/common/mac/file_id.cc
@@ -48,29 +48,29 @@ FileID::FileID(const char *path) {
strlcpy(path_, path, sizeof(path_));
}
bool FileID::FileIdentifier(unsigned char identifier[16]) {
int fd = open(path_, O_RDONLY);
if (fd == -1)
return false;
- MD5_CTX md5;
- MD5_Init(&md5);
+ MD5Context md5;
+ MD5Init(&md5);
// 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.
unsigned char buffer[4096 * 2];
size_t buffer_size = sizeof(buffer);
while ((buffer_size = read(fd, buffer, buffer_size) > 0)) {
- MD5_Update(&md5, buffer, buffer_size);
+ MD5Update(&md5, buffer, buffer_size);
}
close(fd);
- MD5_Final(identifier, &md5);
+ MD5Final(identifier, &md5);
return true;
}
bool FileID::MachoIdentifier(int cpu_type, unsigned char identifier[16]) {
MachoID macho(path_);
if (macho.UUIDCommand(cpu_type, identifier))
--- a/toolkit/crashreporter/google-breakpad/src/common/mac/macho_id.cc
+++ b/toolkit/crashreporter/google-breakpad/src/common/mac/macho_id.cc
@@ -32,26 +32,26 @@
// See macho_id.h for documentation
//
// Author: Dan Waylonis
extern "C" { // necessary for Leopard
#include <fcntl.h>
#include <mach-o/loader.h>
#include <mach-o/swap.h>
- #include <openssl/md5.h>
#include <openssl/sha.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/time.h>
#include <sys/types.h>
#include <unistd.h>
}
+#include "common/md5.h"
#include "common/mac/macho_id.h"
#include "common/mac/macho_walker.h"
#include "common/mac/macho_utilities.h"
namespace MacFileUtilities {
MachoID::MachoID(const char *path)
: file_(0),
@@ -112,17 +112,17 @@ void MachoID::UpdateCRC(unsigned char *b
}
sum1 %= MOD_ADLER;
sum2 %= MOD_ADLER;
crc_ = (sum2 << 16) | sum1;
}
}
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) {
SHA_Update(&sha1_context_, bytes, size);
}
void MachoID::Update(MachoWalker *walker, off_t offset, size_t size) {
if (!update_function_ || !size)
@@ -220,25 +220,22 @@ uint32_t MachoID::Adler32(int cpu_type)
return crc_;
}
bool MachoID::MD5(int cpu_type, unsigned char identifier[16]) {
MachoWalker walker(path_, WalkerCB, this);
update_function_ = &MachoID::UpdateMD5;
- if (MD5_Init(&md5_context_)) {
- if (!walker.WalkHeader(cpu_type))
- return false;
+ MD5Init(&md5_context_);
+ if (!walker.WalkHeader(cpu_type))
+ return false;
- MD5_Final(identifier, &md5_context_);
- return true;
- }
-
- return false;
+ MD5Final(identifier, &md5_context_);
+ return true;
}
bool MachoID::SHA1(int cpu_type, unsigned char identifier[16]) {
MachoWalker walker(path_, WalkerCB, this);
update_function_ = &MachoID::UpdateSHA1;
if (SHA_Init(&sha1_context_)) {
if (!walker.WalkHeader(cpu_type))
--- a/toolkit/crashreporter/google-breakpad/src/common/mac/macho_id.h
+++ b/toolkit/crashreporter/google-breakpad/src/common/mac/macho_id.h
@@ -31,19 +31,20 @@
//
// Author: Dan Waylonis
#ifndef COMMON_MAC_MACHO_ID_H__
#define COMMON_MAC_MACHO_ID_H__
#include <limits.h>
#include <mach-o/loader.h>
-#include <openssl/md5.h>
#include <openssl/sha.h>
+#include "common/md5.h"
+
namespace MacFileUtilities {
class MachoWalker;
class MachoID {
public:
MachoID(const char *path);
~MachoID();
@@ -105,17 +106,17 @@ class MachoID {
// File descriptor
int file_;
// The current crc value
uint32_t crc_;
// The MD5 context
- MD5_CTX md5_context_;
+ MD5Context md5_context_;
// The SHA1 context
SHA_CTX sha1_context_;
// The current update to call from the Update callback
UpdateFunction update_function_;
};