зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1639552 - Use ObfuscatingVFS if a URL containing a key is specified. r=dom-workers-and-storage-reviewers,mak,janv
Differential Revision: https://phabricator.services.mozilla.com/D76172
This commit is contained in:
Родитель
c29475654f
Коммит
1092c0da59
|
@ -622,10 +622,12 @@ static const char* obfsNextSystemCall(sqlite3_vfs* pVfs, const char* zName) {
|
|||
namespace mozilla {
|
||||
namespace storage {
|
||||
|
||||
const char* GetObfuscatingVFSName() { return "obfsvfs"; }
|
||||
|
||||
UniquePtr<sqlite3_vfs> ConstructObfuscatingVFS(const char* aBaseVFSName) {
|
||||
MOZ_ASSERT(aBaseVFSName);
|
||||
|
||||
if (sqlite3_vfs_find("obfs") != nullptr) {
|
||||
if (sqlite3_vfs_find(GetObfuscatingVFSName()) != nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
sqlite3_vfs* const pOrig = sqlite3_vfs_find(aBaseVFSName);
|
||||
|
@ -646,7 +648,7 @@ UniquePtr<sqlite3_vfs> ConstructObfuscatingVFS(const char* aBaseVFSName) {
|
|||
static_cast<int>(pOrig->szOsFile + sizeof(ObfsFile)), /* szOsFile */
|
||||
1024, /* mxPathname */
|
||||
nullptr, /* pNext */
|
||||
"obfsvfs", /* zName */
|
||||
GetObfuscatingVFSName(), /* zName */
|
||||
pOrig, /* pAppData */
|
||||
obfsOpen, /* xOpen */
|
||||
obfsDelete, /* xDelete */
|
||||
|
|
|
@ -44,6 +44,9 @@
|
|||
#include "nsProxyRelease.h"
|
||||
#include <algorithm>
|
||||
|
||||
// XXX Remove the dependency on dom/url after Bug 1673682
|
||||
#include "mozilla/dom/URLSearchParams.h"
|
||||
|
||||
#define MIN_AVAILABLE_BYTES_PER_CHUNKED_GROWTH 524288000 // 500 MiB
|
||||
|
||||
// Maximum size of the pages cache per connection.
|
||||
|
@ -77,6 +80,7 @@ using mozilla::Telemetry::LABELS_SQLITE_STORE_OPEN;
|
|||
using mozilla::Telemetry::LABELS_SQLITE_STORE_QUERY;
|
||||
|
||||
const char* GetTelemetryVFSName(bool);
|
||||
const char* GetObfuscatingVFSName();
|
||||
|
||||
namespace {
|
||||
|
||||
|
@ -755,6 +759,19 @@ nsresult Connection::initialize(nsIFile* aDatabaseFile) {
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
static bool HasKeyParam(const nsACString& aQuery) {
|
||||
class MOZ_STACK_CLASS ParamsIterator final
|
||||
: public dom::URLParams::ForEachIterator {
|
||||
public:
|
||||
bool URLParamsIterator(const nsAString& aName,
|
||||
const nsAString& aValue) override {
|
||||
return aName.EqualsLiteral("key");
|
||||
}
|
||||
} paramsIterator;
|
||||
|
||||
return dom::URLParams::Parse(aQuery, paramsIterator);
|
||||
}
|
||||
|
||||
nsresult Connection::initialize(nsIFileURL* aFileURL,
|
||||
const nsACString& aTelemetryFilename) {
|
||||
NS_ASSERTION(aFileURL, "Passed null file URL!");
|
||||
|
@ -781,8 +798,14 @@ nsresult Connection::initialize(nsIFileURL* aFileURL,
|
|||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
bool exclusive = StaticPrefs::storage_sqlite_exclusiveLock_enabled();
|
||||
int srv = ::sqlite3_open_v2(spec.get(), &mDBConn, mFlags,
|
||||
GetTelemetryVFSName(exclusive));
|
||||
|
||||
// If there is a key specified, we need to use the obfuscating VFS.
|
||||
nsAutoCString query;
|
||||
rv = aFileURL->GetQuery(query);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
const char* const vfs = HasKeyParam(query) ? GetObfuscatingVFSName()
|
||||
: GetTelemetryVFSName(exclusive);
|
||||
int srv = ::sqlite3_open_v2(spec.get(), &mDBConn, mFlags, vfs);
|
||||
if (srv != SQLITE_OK) {
|
||||
mDBConn = nullptr;
|
||||
rv = convertResultCode(srv);
|
||||
|
|
Загрузка…
Ссылка в новой задаче