зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1621916 - Fix IndexedDB to ignore unknown files in the files and journals directory during initialization and usage calculation; r=dom-workers-and-storage-reviewers,ttung
All unknown files in the files and journals directory are now properly filtered out if the filename can't be converted to an integer. Differential Revision: https://phabricator.services.mozilla.com/D76703
This commit is contained in:
Родитель
e93eaffe2e
Коммит
68a6cbf429
|
@ -142,6 +142,12 @@
|
||||||
# define IDB_MOBILE
|
# define IDB_MOBILE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define UNKNOWN_FILE_WARNING(_leafName) \
|
||||||
|
NS_WARNING( \
|
||||||
|
nsPrintfCString("Something (%s) in the directory that doesn't belong!", \
|
||||||
|
NS_ConvertUTF16toUTF8(_leafName).get()) \
|
||||||
|
.get())
|
||||||
|
|
||||||
namespace mozilla {
|
namespace mozilla {
|
||||||
|
|
||||||
MOZ_TYPE_SPECIFIC_SCOPED_POINTER_TEMPLATE(ScopedPRFileDesc, PRFileDesc,
|
MOZ_TYPE_SPECIFIC_SCOPED_POINTER_TEMPLATE(ScopedPRFileDesc, PRFileDesc,
|
||||||
|
@ -16684,13 +16690,32 @@ nsresult FileManager::InitDirectory(nsIFile& aDirectory, nsIFile& aDatabaseFile,
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool hasElements;
|
bool hasJournals = false;
|
||||||
rv = entries->HasMoreElements(&hasElements);
|
|
||||||
|
nsCOMPtr<nsIFile> file;
|
||||||
|
while (NS_SUCCEEDED((rv = entries->GetNextFile(getter_AddRefs(file)))) &&
|
||||||
|
file) {
|
||||||
|
nsString leafName;
|
||||||
|
rv = file->GetLeafName(leafName);
|
||||||
|
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
|
||||||
|
leafName.ToInteger64(&rv);
|
||||||
|
if (NS_SUCCEEDED(rv)) {
|
||||||
|
hasJournals = true;
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
UNKNOWN_FILE_WARNING(leafName);
|
||||||
|
}
|
||||||
|
|
||||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hasElements) {
|
if (hasJournals) {
|
||||||
auto connectionOrErr = CreateStorageConnection(
|
auto connectionOrErr = CreateStorageConnection(
|
||||||
aDatabaseFile, aDirectory, VoidString(), aOrigin,
|
aDatabaseFile, aDirectory, VoidString(), aOrigin,
|
||||||
/* aDirectoryLockId */ -1, aTelemetryId);
|
/* aDirectoryLockId */ -1, aTelemetryId);
|
||||||
|
@ -16739,6 +16764,11 @@ nsresult FileManager::InitDirectory(nsIFile& aDirectory, nsIFile& aDatabaseFile,
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
name.ToInteger64(&rv);
|
||||||
|
if (NS_FAILED(rv)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
int32_t flag = stmt->AsInt32(1);
|
int32_t flag = stmt->AsInt32(1);
|
||||||
|
|
||||||
if (!flag) {
|
if (!flag) {
|
||||||
|
@ -16830,13 +16860,20 @@ nsresult FileManager::GetUsage(nsIFile* aDirectory, Maybe<uint64_t>& aUsage) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t fileSize;
|
leafName.ToInteger64(&rv);
|
||||||
rv = file->GetFileSize(&fileSize);
|
if (NS_SUCCEEDED(rv)) {
|
||||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
int64_t fileSize;
|
||||||
return rv;
|
rv = file->GetFileSize(&fileSize);
|
||||||
|
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
|
||||||
|
UsageInfo::IncrementUsage(usage, Some(uint64_t(fileSize)));
|
||||||
|
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
UsageInfo::IncrementUsage(usage, Some(uint64_t(fileSize)));
|
UNKNOWN_FILE_WARNING(leafName);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||||
|
@ -17785,6 +17822,14 @@ nsresult QuotaClient::GetUsageForDirectoryInternal(nsIFile* aDirectory,
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!aDatabaseFiles) {
|
||||||
|
leafName.ToInteger64(&rv);
|
||||||
|
if (NS_FAILED(rv)) {
|
||||||
|
UNKNOWN_FILE_WARNING(leafName);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int64_t fileSize;
|
int64_t fileSize;
|
||||||
rv = file->GetFileSize(&fileSize);
|
rv = file->GetFileSize(&fileSize);
|
||||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||||
|
|
|
@ -84,6 +84,12 @@ async function testSteps() {
|
||||||
|
|
||||||
// TODO: Fix IndexedDB to ignore unknown files as well
|
// TODO: Fix IndexedDB to ignore unknown files as well
|
||||||
// createUnknownFileIn(`${originRelativePath}/idb`);
|
// createUnknownFileIn(`${originRelativePath}/idb`);
|
||||||
|
createUnknownFileIn(
|
||||||
|
`${originRelativePath}/idb/2320029346mByDIdnedxe.files`
|
||||||
|
);
|
||||||
|
createUnknownFileIn(
|
||||||
|
`${originRelativePath}/idb/2320029346mByDIdnedxe.files/journals`
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Unknown file in cache client directory
|
// Unknown file in cache client directory
|
||||||
|
|
Двоичные данные
dom/quota/test/xpcshell/unknownFiles_profile.zip
Двоичные данные
dom/quota/test/xpcshell/unknownFiles_profile.zip
Двоичный файл не отображается.
Загрузка…
Ссылка в новой задаче