Fix orphaned crash reports.

The path NSCachesDirectory may change across app updates and sometimes
even across app launches. As a result, the Config-XXX files may end up
with an outdated path to the associated minidump file.

Change-Id: I0befde26b2ac406c154ce7c7e9be0063ee99892d
Bug:850379
Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/1592561
Reviewed-by: Mark Mentovai <mark@chromium.org>
diff --git a/src/client/ios/Breakpad.mm b/src/client/ios/Breakpad.mm
index 2d8ba61..2b61bbe 100644
--- a/src/client/ios/Breakpad.mm
+++ b/src/client/ios/Breakpad.mm
@@ -161,6 +161,7 @@
   NSArray *CrashReportsToUpload();
   NSString *NextCrashReportToUpload();
   NSDictionary *NextCrashReportConfiguration();
+  NSDictionary *FixedUpCrashReportConfiguration(NSDictionary *configuration);
   NSDate *DateOfMostRecentCrashReport();
   void UploadNextReport(NSDictionary *server_parameters);
   void UploadReportWithConfiguration(NSDictionary *configuration,
@@ -466,7 +467,18 @@
 
 //=============================================================================
 NSDictionary *Breakpad::NextCrashReportConfiguration() {
-  return [Uploader readConfigurationDataFromFile:NextCrashReportToUpload()];
+  NSDictionary *configuration = [Uploader readConfigurationDataFromFile:NextCrashReportToUpload()];
+  return FixedUpCrashReportConfiguration(configuration);
+}
+
+//=============================================================================
+NSDictionary *Breakpad::FixedUpCrashReportConfiguration(NSDictionary *configuration) {
+  NSMutableDictionary *fixedConfiguration = [[configuration mutableCopy] autorelease];
+  // kReporterMinidumpDirectoryKey can become stale because the app's data container path includes
+  // an UUID that is not guaranteed to stay the same over time.
+  [fixedConfiguration setObject:KeyValue(@BREAKPAD_DUMP_DIRECTORY)
+                    forKey:@kReporterMinidumpDirectoryKey];
+  return fixedConfiguration;
 }
 
 //=============================================================================