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

Unified Diff: util/mach/mach_message.cc

Issue 1001943002: handler/mac: Log a warning when an exception message has a suspicious (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: MACH_MSG_TYPE_MAKE_SEND_ONCE Created 5 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « util/mach/mach_message.h ('k') | util/mach/mach_message_test.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: util/mach/mach_message.cc
diff --git a/util/mach/mach_message.cc b/util/mach/mach_message.cc
index 4d23eb25d3535a1f31fe4221e0841867d5bf2b52..8092f26c1171b241a008a10842741a0ac2706987 100644
--- a/util/mach/mach_message.cc
+++ b/util/mach/mach_message.cc
@@ -14,9 +14,13 @@
#include "util/mach/mach_message.h"
+#include <AvailabilityMacros.h>
+#include <bsm/libbsm.h>
+
#include <limits>
#include "base/basictypes.h"
+#include "base/logging.h"
#include "util/misc/clock.h"
namespace crashpad {
@@ -213,4 +217,36 @@ const mach_msg_trailer_t* MachMessageTrailerFromHeader(
return reinterpret_cast<const mach_msg_trailer_t*>(trailer_address);
}
+pid_t AuditPIDFromMachMessageTrailer(const mach_msg_trailer_t* trailer) {
+ if (trailer->msgh_trailer_type != MACH_MSG_TRAILER_FORMAT_0) {
+ LOG(ERROR) << "unexpected msgh_trailer_type " << trailer->msgh_trailer_type;
+ return -1;
+ }
+ if (trailer->msgh_trailer_size <
+ REQUESTED_TRAILER_SIZE(kMachMessageReceiveAuditTrailer)) {
+ LOG(ERROR) << "small msgh_trailer_size " << trailer->msgh_trailer_size;
+ return -1;
+ }
+
+ const mach_msg_audit_trailer_t* audit_trailer =
+ reinterpret_cast<const mach_msg_audit_trailer_t*>(trailer);
+
+#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_8
+ pid_t audit_pid;
+ audit_token_to_au32(audit_trailer->msgh_audit,
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ nullptr,
+ &audit_pid,
+ nullptr,
+ nullptr);
+#else
+ pid_t audit_pid = audit_token_to_pid(audit_trailer->msgh_audit);
+#endif
+
+ return audit_pid;
+}
+
} // namespace crashpad
« no previous file with comments | « util/mach/mach_message.h ('k') | util/mach/mach_message_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698