aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorladderbreaker <ladderbreaker@4c0a9323-5329-0410-9bdc-e9ce6186880e>2007-03-16 17:51:43 +0000
committerladderbreaker <ladderbreaker@4c0a9323-5329-0410-9bdc-e9ce6186880e>2007-03-16 17:51:43 +0000
commit1a4310017ec3af237399ccbc4ff096de4c08cf6d (patch)
tree1f59ec5d5f852ccb7a0b700e5e7eaf9e40674b6b /src
parentAdd Linux exception handler. (diff)
downloadbreakpad-1a4310017ec3af237399ccbc4ff096de4c08cf6d.tar.xz
issue 133: Mach-o UUID generation has problems - reviewed by waylonis
git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@127 4c0a9323-5329-0410-9bdc-e9ce6186880e
Diffstat (limited to 'src')
-rw-r--r--src/common/mac/macho_id.cc19
1 files changed, 13 insertions, 6 deletions
diff --git a/src/common/mac/macho_id.cc b/src/common/mac/macho_id.cc
index 5fc8bbf8..9605166e 100644
--- a/src/common/mac/macho_id.cc
+++ b/src/common/mac/macho_id.cc
@@ -170,12 +170,19 @@ bool MachoID::IDCommand(int cpu_type, unsigned char identifier[16]) {
// If we found the command, we'll have initialized the dylib_command
// structure
if (dylib_cmd.cmd == LC_ID_DYLIB) {
- // Take the timestamp, version, and compatability version bytes to form
- // the first 12 bytes, pad the rest with zeros
- identifier[0] = (dylib_cmd.dylib.timestamp >> 24) & 0xFF;
- identifier[1] = (dylib_cmd.dylib.timestamp >> 16) & 0xFF;
- identifier[2] = (dylib_cmd.dylib.timestamp >> 8) & 0xFF;
- identifier[3] = dylib_cmd.dylib.timestamp & 0xFF;
+ // Take the hashed filename, version, and compatability version bytes
+ // to form the first 12 bytes, pad the rest with zeros
+
+ // create a crude hash of the filename to generate the first 4 bytes
+ identifier[0] = 0;
+ identifier[1] = 0;
+ identifier[2] = 0;
+ identifier[3] = 0;
+
+ for (int j = 0, i = strlen(path_)-1; i >= 0 && path_[i]!='/'; ++j, --i) {
+ identifier[j%4] += path_[i];
+ }
+
identifier[4] = (dylib_cmd.dylib.current_version >> 24) & 0xFF;
identifier[5] = (dylib_cmd.dylib.current_version >> 16) & 0xFF;
identifier[6] = (dylib_cmd.dylib.current_version >> 8) & 0xFF;