Bug 1562822 - P1. Return NS_ERROR_FILE_CORRUPTED when Safe Browsing cannot read the header of its database. r=gcp
authordlee <dlee@mozilla.com>
Wed, 21 Aug 2019 12:07:44 +0000
changeset 489173 7a0ab3a7558b4fc930d1066f3f204ee99ccfc162
parent 489172 843d5ffdc4d4a4e2157440ba53e6cec55783a88f
child 489174 d49cd2aa45686212954493e2465fc3258c1796a2
push id36465
push userdvarga@mozilla.com
push dateWed, 21 Aug 2019 16:47:43 +0000
treeherdermozilla-central@4ab60925635c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgcp
bugs1562822
milestone70.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1562822 - P1. Return NS_ERROR_FILE_CORRUPTED when Safe Browsing cannot read the header of its database. r=gcp Differential Revision: https://phabricator.services.mozilla.com/D42613
toolkit/components/url-classifier/HashStore.cpp
toolkit/components/url-classifier/LookupCache.cpp
--- a/toolkit/components/url-classifier/HashStore.cpp
+++ b/toolkit/components/url-classifier/HashStore.cpp
@@ -328,17 +328,20 @@ nsresult HashStore::Open(uint32_t aVersi
   }
 
   mFileSize = static_cast<uint32_t>(fileSize);
   rv = NS_NewBufferedInputStream(getter_AddRefs(mInputStream),
                                  origStream.forget(), mFileSize);
   NS_ENSURE_SUCCESS(rv, rv);
 
   rv = ReadHeader();
-  NS_ENSURE_SUCCESS(rv, rv);
+  if (NS_WARN_IF(NS_FAILED(rv))) {
+    LOG(("Failed to read header for %s", mTableName.get()));
+    return NS_ERROR_FILE_CORRUPTED;
+  }
 
   rv = SanityCheck(aVersion);
   NS_ENSURE_SUCCESS(rv, rv);
 
   return NS_OK;
 }
 
 nsresult HashStore::ReadHeader() {
--- a/toolkit/components/url-classifier/LookupCache.cpp
+++ b/toolkit/components/url-classifier/LookupCache.cpp
@@ -679,17 +679,18 @@ nsresult LookupCache::LoadFromFile(nsCOM
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
 
   // Load header
   Header header;
   rv = ReadValue(in, header);
   if (NS_WARN_IF(NS_FAILED(rv))) {
-    return rv;
+    LOG(("Failed to read header for %s", mTableName.get()));
+    return NS_ERROR_FILE_CORRUPTED;
   }
 
   rv = SanityCheck(header);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
 
   // Load data