Bug 1719319: Don't try to use the URLPreloader cache before it's fully initialized. r=mccr8

Anything accessed before that time won't benefit from caching, and having
entries inserted into the hashtable before the cache file is read may lead to
undefined behavior.

This bug shouldn't be exploitable, since it only affects file reads that
happen long before any untrusted code has a chance to run.

Differential Revision: https://phabricator.services.mozilla.com/D120391
This commit is contained in:
Kris Maglione 2021-07-27 20:29:09 +00:00
Родитель 560b3e7e98
Коммит a4da20eee2
1 изменённых файлов: 2 добавлений и 1 удалений

Просмотреть файл

@ -11,6 +11,7 @@
#include "mozilla/ArrayUtils.h"
#include "mozilla/ClearOnShutdown.h"
#include "mozilla/FileUtils.h"
#include "mozilla/IOBuffers.h"
#include "mozilla/Logging.h"
#include "mozilla/ScopeExit.h"
#include "mozilla/Services.h"
@ -452,7 +453,7 @@ void URLPreloader::BeginBackgroundRead() {
Result<nsCString, nsresult> URLPreloader::ReadInternal(const CacheKey& key,
ReadType readType) {
if (mStartupFinished) {
if (mStartupFinished || !mReaderInitialized) {
URLEntry entry(key);
return entry.Read();