Bug 1516333 - Part 1: Move group and origin re-escaping from QuotaManager::GetQuotaObject to GetQuotaObjectFromNameAndParameters in TelemetryVFS.cpp; r=janv,asuth a=jcristau
authorEden Chuang <echuang@mozilla.com>
Fri, 07 Jun 2019 08:04:57 +0200
changeset 536763 d13ae743074c0570c499c217c1cf9262f74a28c4
parent 536762 2e75aceef9df66dbbfce6ae0f8c1638425d528df
child 536764 eacd2f22961f47f00d357814c55d8e707bf5598b
push id2082
push userffxbld-merge
push dateMon, 01 Jul 2019 08:34:18 +0000
treeherdermozilla-release@2fb19d0466d2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjanv, asuth, jcristau
bugs1516333
milestone68.0
Bug 1516333 - Part 1: Move group and origin re-escaping from QuotaManager::GetQuotaObject to GetQuotaObjectFromNameAndParameters in TelemetryVFS.cpp; r=janv,asuth a=jcristau Differential Revision: https://phabricator.services.mozilla.com/D33769
dom/quota/ActorsParent.cpp
storage/TelemetryVFS.cpp
--- a/dom/quota/ActorsParent.cpp
+++ b/dom/quota/ActorsParent.cpp
@@ -3746,41 +3746,32 @@ already_AddRefed<QuotaObject> QuotaManag
       NS_ENSURE_SUCCESS(rv, nullptr);
     } else {
       fileSize = 0;
     }
   } else {
     fileSize = aFileSize;
   }
 
-  // Re-escape our parameters above to make sure we get the right quota group.
-  nsAutoCString group;
-  rv = NS_EscapeURL(aGroup, esc_Query, group, fallible);
-  NS_ENSURE_SUCCESS(rv, nullptr);
-
-  nsAutoCString origin;
-  rv = NS_EscapeURL(aOrigin, esc_Query, origin, fallible);
-  NS_ENSURE_SUCCESS(rv, nullptr);
-
   RefPtr<QuotaObject> result;
   {
     MutexAutoLock lock(mQuotaMutex);
 
     GroupInfoPair* pair;
-    if (!mGroupInfoPairs.Get(group, &pair)) {
+    if (!mGroupInfoPairs.Get(aGroup, &pair)) {
       return nullptr;
     }
 
     RefPtr<GroupInfo> groupInfo = pair->LockedGetGroupInfo(aPersistenceType);
 
     if (!groupInfo) {
       return nullptr;
     }
 
-    RefPtr<OriginInfo> originInfo = groupInfo->LockedGetOriginInfo(origin);
+    RefPtr<OriginInfo> originInfo = groupInfo->LockedGetOriginInfo(aOrigin);
 
     if (!originInfo) {
       return nullptr;
     }
 
     // We need this extra raw pointer because we can't assign to the smart
     // pointer directly since QuotaObject::AddRef would try to acquire the same
     // mutex.
--- a/storage/TelemetryVFS.cpp
+++ b/storage/TelemetryVFS.cpp
@@ -9,16 +9,17 @@
 #include "mozilla/Preferences.h"
 #include "sqlite3.h"
 #include "nsThreadUtils.h"
 #include "mozilla/dom/quota/PersistenceType.h"
 #include "mozilla/dom/quota/QuotaManager.h"
 #include "mozilla/dom/quota/QuotaObject.h"
 #include "mozilla/net/IOActivityMonitor.h"
 #include "mozilla/IOInterposer.h"
+#include "nsEscape.h"
 
 // The last VFS version for which this file has been updated.
 #define LAST_KNOWN_VFS_VERSION 3
 
 // The last io_methods version for which this file has been updated.
 #define LAST_KNOWN_IOMETHODS_VERSION 3
 
 /**
@@ -313,23 +314,37 @@ already_AddRefed<QuotaObject> GetQuotaOb
   const char* origin = sqlite3_uri_parameter(zURIParameterKey, "origin");
   if (!origin) {
     NS_WARNING(
         "SQLite URI had 'persistenceType' and 'group' but not "
         "'origin'?!");
     return nullptr;
   }
 
+  // Re-escape group and origin to make sure we get the right quota group and
+  // origin.
+  nsAutoCString escGroup;
+  nsresult rv =
+      NS_EscapeURL(nsDependentCString(group), esc_Query, escGroup, fallible);
+  if (NS_WARN_IF(NS_FAILED(rv))) {
+    return nullptr;
+  }
+
+  nsAutoCString escOrigin;
+  rv = NS_EscapeURL(nsDependentCString(origin), esc_Query, escOrigin, fallible);
+  if (NS_WARN_IF(NS_FAILED(rv))) {
+    return nullptr;
+  }
+
   QuotaManager* quotaManager = QuotaManager::Get();
   MOZ_ASSERT(quotaManager);
 
   return quotaManager->GetQuotaObject(
-      PersistenceTypeFromText(nsDependentCString(persistenceType)),
-      nsDependentCString(group), nsDependentCString(origin),
-      NS_ConvertUTF8toUTF16(zName));
+      PersistenceTypeFromText(nsDependentCString(persistenceType)), escGroup,
+      escOrigin, NS_ConvertUTF8toUTF16(zName));
 }
 
 void MaybeEstablishQuotaControl(const char* zName, telemetry_file* pFile,
                                 int flags) {
   MOZ_ASSERT(pFile);
   MOZ_ASSERT(!pFile->quotaObject);
 
   if (!(flags & (SQLITE_OPEN_URI | SQLITE_OPEN_WAL))) {