Bug 1662809 - don't copy key-value pairs from blocklist entries during parsing; r=aosmond

Instead of splitting the entire entry into an `nsTArray`, we can use
`nsTSubstring::Split` to provide dependent strings into the entry.  We copy
the actual keys and values later, so this should be perfectly safe.

Depends on D89168

Differential Revision: https://phabricator.services.mozilla.com/D89169
This commit is contained in:
Nathan Froyd 2020-09-02 16:58:33 +00:00
Родитель 61491490cb
Коммит b1a57a4701
1 изменённых файлов: 2 добавлений и 6 удалений

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

@ -490,19 +490,15 @@ static bool BlocklistEntryToDriverInfo(nsCString& aBlocklistEntry,
<< GfxInfoBase::GetApplicationVersion().get();
}
nsTArray<nsCString> keyValues;
ParseString(aBlocklistEntry, '\t', keyValues);
aDriverInfo.mRuleId = "FEATURE_FAILURE_DL_BLOCKLIST_NO_ID"_ns;
for (uint32_t i = 0; i < keyValues.Length(); ++i) {
const nsCString& keyValue = keyValues[i];
for (const auto& keyValue : aBlocklistEntry.Split('\t')) {
nsTArray<nsCString> splitted;
ParseString(keyValue, ':', splitted);
if (splitted.Length() != 2) {
// If we don't recognize the input data, we do not want to proceed.
gfxCriticalErrorOnce(CriticalLog::DefaultOptions(false))
<< "Unrecognized data " << keyValue.get();
<< "Unrecognized data " << nsCString(keyValue).get();
return false;
}
const nsCString& key = splitted[0];