Index: client/crash_report_database_mac.mm |
diff --git a/client/crash_report_database_mac.mm b/client/crash_report_database_mac.mm |
index b849bb0f66ba365011e397e9205a19cfa0520dd9..d588f7658cc26225cce860c604c685e19dd91914 100644 |
--- a/client/crash_report_database_mac.mm |
+++ b/client/crash_report_database_mac.mm |
@@ -238,15 +238,15 @@ CrashReportDatabase::OperationStatus |
CrashReportDatabaseMac::PrepareNewCrashReport(NewReport** out_report) { |
INITIALIZATION_STATE_DCHECK_VALID(initialized_); |
+ scoped_ptr<NewReport> report(new NewReport()); |
+ |
uuid_t uuid_gen; |
uuid_generate(uuid_gen); |
- UUID uuid(uuid_gen); |
- |
- scoped_ptr<NewReport> report(new NewReport()); |
+ report->uuid.InitializeFromBytes(uuid_gen); |
report->path = |
base_dir_.Append(kWriteDirectory) |
- .Append(uuid.ToString() + "." + kCrashReportFileExtension); |
+ .Append(report->uuid.ToString() + "." + kCrashReportFileExtension); |
report->handle = HANDLE_EINTR(open(report->path.value().c_str(), |
O_CREAT | O_WRONLY | O_EXCL | O_EXLOCK, |
@@ -257,7 +257,8 @@ CrashReportDatabaseMac::PrepareNewCrashReport(NewReport** out_report) { |
} |
// TODO(rsesek): Potentially use an fsetxattr() here instead. |
- if (!WriteXattr(report->path, XattrName(kXattrUUID), uuid.ToString())) { |
+ if (!WriteXattr( |
+ report->path, XattrName(kXattrUUID), report->uuid.ToString())) { |
PLOG_IF(ERROR, IGNORE_EINTR(close(report->handle)) != 0) << "close"; |
return kDatabaseError; |
} |
@@ -288,6 +289,11 @@ CrashReportDatabaseMac::FinishedWritingCrashReport(NewReport* report, |
return kDatabaseError; |
} |
+ if (*uuid != report->uuid) { |
+ LOG(ERROR) << "UUID mismatch for crash report " << report->path.value(); |
+ return kDatabaseError; |
+ } |
+ |
// Record the creation time of this report. |
if (!WriteXattrTimeT(report->path, XattrName(kXattrCreationTime), |
time(nullptr))) { |