Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(12)

Side by Side Diff: src/common/mac/file_id.cc

Issue 1340543002: Fix Mac Breakpad host tools to build in Linux cross-compile (Closed) Base URL: https://chromium.googlesource.com/breakpad/breakpad.git@master
Patch Set: Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2006, Google Inc. 1 // Copyright (c) 2006, Google Inc.
2 // All rights reserved. 2 // All rights reserved.
3 // 3 //
4 // Redistribution and use in source and binary forms, with or without 4 // Redistribution and use in source and binary forms, with or without
5 // modification, are permitted provided that the following conditions are 5 // modification, are permitted provided that the following conditions are
6 // met: 6 // met:
7 // 7 //
8 // * Redistributions of source code must retain the above copyright 8 // * Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer. 9 // notice, this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above 10 // * Redistributions in binary form must reproduce the above
(...skipping 27 matching lines...) Expand all
38 #include <unistd.h> 38 #include <unistd.h>
39 39
40 #include "common/mac/file_id.h" 40 #include "common/mac/file_id.h"
41 #include "common/mac/macho_id.h" 41 #include "common/mac/macho_id.h"
42 42
43 using MacFileUtilities::MachoID; 43 using MacFileUtilities::MachoID;
44 44
45 namespace google_breakpad { 45 namespace google_breakpad {
46 46
47 FileID::FileID(const char *path) { 47 FileID::FileID(const char *path) {
48 strlcpy(path_, path, sizeof(path_)); 48 strncpy(path_, path, sizeof(path_) - 1);
Mark Mentovai 2015/09/11 15:49:50 strlcpy() guarantees NUL-termination, but strncpy(
Ted Mielczarek 2015/09/15 12:58:36 Done.
49 } 49 }
50 50
51 bool FileID::FileIdentifier(unsigned char identifier[16]) { 51 bool FileID::FileIdentifier(unsigned char identifier[16]) {
52 int fd = open(path_, O_RDONLY); 52 int fd = open(path_, O_RDONLY);
53 if (fd == -1) 53 if (fd == -1)
54 return false; 54 return false;
55 55
56 MD5Context md5; 56 MD5Context md5;
57 MD5Init(&md5); 57 MD5Init(&md5);
58 58
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 static_cast<char>((hi >= 10) ? ('A' + hi - 10) : ('0' + hi)); 96 static_cast<char>((hi >= 10) ? ('A' + hi - 10) : ('0' + hi));
97 buffer[buffer_idx++] = 97 buffer[buffer_idx++] =
98 static_cast<char>((lo >= 10) ? ('A' + lo - 10) : ('0' + lo)); 98 static_cast<char>((lo >= 10) ? ('A' + lo - 10) : ('0' + lo));
99 } 99 }
100 100
101 // NULL terminate 101 // NULL terminate
102 buffer[(buffer_idx < buffer_length) ? buffer_idx : buffer_idx - 1] = 0; 102 buffer[(buffer_idx < buffer_length) ? buffer_idx : buffer_idx - 1] = 0;
103 } 103 }
104 104
105 } // namespace google_breakpad 105 } // namespace google_breakpad
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698