mirror of
https://git.suyu.dev/suyu/breakpad.git
synced 2026-02-06 21:34:02 +00:00
This libcrypto dependency sucks. Linking against OpenSSL is sort of broken in certain Mac OS X SDKs. libcrypto was only being used to provide an MD5 implementation. Breakpad already has its own MD5 implementation, so just use that instead. To be perfectly honest, on modern systems, nothing should be making MD5 hashes of modules anyway, because everything has an embedded LC_UUID. The project file changes just remove libcrypto and add md5.c as needed. A bonus (and untested) fix for on_demand_symbol_supplier.mm is included to account for changes in r794. Review URL: http://breakpad.appspot.com/296001 git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@819 4c0a9323-5329-0410-9bdc-e9ce6186880e
114 lines
4.0 KiB
C++
114 lines
4.0 KiB
C++
// Copyright (c) 2006, Google Inc.
|
|
// All rights reserved.
|
|
//
|
|
// Redistribution and use in source and binary forms, with or without
|
|
// modification, are permitted provided that the following conditions are
|
|
// met:
|
|
//
|
|
// * Redistributions of source code must retain the above copyright
|
|
// notice, this list of conditions and the following disclaimer.
|
|
// * Redistributions in binary form must reproduce the above
|
|
// copyright notice, this list of conditions and the following disclaimer
|
|
// in the documentation and/or other materials provided with the
|
|
// distribution.
|
|
// * Neither the name of Google Inc. nor the names of its
|
|
// contributors may be used to endorse or promote products derived from
|
|
// this software without specific prior written permission.
|
|
//
|
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
// macho_id.h: Functions to gather identifying information from a macho file
|
|
//
|
|
// Author: Dan Waylonis
|
|
|
|
#ifndef COMMON_MAC_MACHO_ID_H__
|
|
#define COMMON_MAC_MACHO_ID_H__
|
|
|
|
#include <limits.h>
|
|
#include <mach-o/loader.h>
|
|
|
|
#include "common/md5.h"
|
|
|
|
namespace MacFileUtilities {
|
|
|
|
class MachoWalker;
|
|
|
|
class MachoID {
|
|
public:
|
|
MachoID(const char *path);
|
|
~MachoID();
|
|
|
|
// For the given |cpu_type|, return a UUID from the LC_UUID command.
|
|
// Return false if there isn't a LC_UUID command.
|
|
bool UUIDCommand(int cpu_type, unsigned char identifier[16]);
|
|
|
|
// For the given |cpu_type|, return a UUID from the LC_ID_DYLIB command.
|
|
// Return false if there isn't a LC_ID_DYLIB command.
|
|
bool IDCommand(int cpu_type, unsigned char identifier[16]);
|
|
|
|
// For the given |cpu_type|, return the Adler32 CRC for the mach-o data
|
|
// segment(s).
|
|
// Return 0 on error (e.g., if the file is not a mach-o file)
|
|
uint32_t Adler32(int cpu_type);
|
|
|
|
// For the given |cpu_type|, return the MD5 for the mach-o data segment(s).
|
|
// Return true on success, false otherwise
|
|
bool MD5(int cpu_type, unsigned char identifier[16]);
|
|
|
|
private:
|
|
// Signature of class member function to be called with data read from file
|
|
typedef void (MachoID::*UpdateFunction)(unsigned char *bytes, size_t size);
|
|
|
|
// Update the CRC value by examining |size| |bytes| and applying the algorithm
|
|
// to each byte.
|
|
void UpdateCRC(unsigned char *bytes, size_t size);
|
|
|
|
// Update the MD5 value by examining |size| |bytes| and applying the algorithm
|
|
// to each byte.
|
|
void UpdateMD5(unsigned char *bytes, size_t size);
|
|
|
|
// Bottleneck for update routines
|
|
void Update(MachoWalker *walker, off_t offset, size_t size);
|
|
|
|
// The callback from the MachoWalker for CRC and MD5
|
|
static bool WalkerCB(MachoWalker *walker, load_command *cmd, off_t offset,
|
|
bool swap, void *context);
|
|
|
|
// The callback from the MachoWalker for LC_UUID
|
|
static bool UUIDWalkerCB(MachoWalker *walker, load_command *cmd, off_t offset,
|
|
bool swap, void *context);
|
|
|
|
// The callback from the MachoWalker for LC_ID_DYLIB
|
|
static bool IDWalkerCB(MachoWalker *walker, load_command *cmd, off_t offset,
|
|
bool swap, void *context);
|
|
|
|
// File path
|
|
char path_[PATH_MAX];
|
|
|
|
// File descriptor
|
|
int file_;
|
|
|
|
// The current crc value
|
|
uint32_t crc_;
|
|
|
|
// The MD5 context
|
|
MD5Context md5_context_;
|
|
|
|
// The current update to call from the Update callback
|
|
UpdateFunction update_function_;
|
|
};
|
|
|
|
} // namespace MacFileUtilities
|
|
|
|
#endif // COMMON_MAC_MACHO_ID_H__
|