mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Backed out changeset bc7ca0aabb24 (bug 1134885) for bustage on a CLOSED TREE
This commit is contained in:
parent
674f511234
commit
b17802c44c
@ -41,9 +41,7 @@ ChunkSet::Set(uint32_t aChunk)
|
||||
{
|
||||
size_t idx = mChunks.BinaryIndexOf(aChunk);
|
||||
if (idx == nsTArray<uint32_t>::NoIndex) {
|
||||
if (!mChunks.InsertElementSorted(aChunk)) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
mChunks.InsertElementSorted(aChunk);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
@ -89,9 +87,7 @@ ChunkSet::Remove(const ChunkSet& aOther)
|
||||
}
|
||||
}
|
||||
|
||||
if (!mChunks.SetLength(addIter - mChunks.Elements())) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
mChunks.SetLength(addIter - mChunks.Elements());
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ public:
|
||||
uint32_t *End() { return mChunks.Elements() + mChunks.Length(); }
|
||||
|
||||
private:
|
||||
FallibleTArray<uint32_t> mChunks;
|
||||
nsTArray<uint32_t> mChunks;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -123,48 +123,41 @@ namespace safebrowsing {
|
||||
const uint32_t STORE_MAGIC = 0x1231af3b;
|
||||
const uint32_t CURRENT_VERSION = 3;
|
||||
|
||||
nsresult
|
||||
void
|
||||
TableUpdate::NewAddPrefix(uint32_t aAddChunk, const Prefix& aHash)
|
||||
{
|
||||
AddPrefix *add = mAddPrefixes.AppendElement();
|
||||
if (!add) return NS_ERROR_OUT_OF_MEMORY;
|
||||
add->addChunk = aAddChunk;
|
||||
add->prefix = aHash;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
void
|
||||
TableUpdate::NewSubPrefix(uint32_t aAddChunk, const Prefix& aHash, uint32_t aSubChunk)
|
||||
{
|
||||
SubPrefix *sub = mSubPrefixes.AppendElement();
|
||||
if (!sub) return NS_ERROR_OUT_OF_MEMORY;
|
||||
sub->addChunk = aAddChunk;
|
||||
sub->prefix = aHash;
|
||||
sub->subChunk = aSubChunk;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
void
|
||||
TableUpdate::NewAddComplete(uint32_t aAddChunk, const Completion& aHash)
|
||||
{
|
||||
AddComplete *add = mAddCompletes.AppendElement();
|
||||
if (!add) return NS_ERROR_OUT_OF_MEMORY;
|
||||
add->addChunk = aAddChunk;
|
||||
add->complete = aHash;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
void
|
||||
TableUpdate::NewSubComplete(uint32_t aAddChunk, const Completion& aHash, uint32_t aSubChunk)
|
||||
{
|
||||
SubComplete *sub = mSubCompletes.AppendElement();
|
||||
if (!sub) return NS_ERROR_OUT_OF_MEMORY;
|
||||
sub->addChunk = aAddChunk;
|
||||
sub->complete = aHash;
|
||||
sub->subChunk = aSubChunk;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
HashStore::HashStore(const nsACString& aTableName, nsIFile* aStoreDir)
|
||||
: mTableName(aTableName)
|
||||
, mStoreDirectory(aStoreDir)
|
||||
|
@ -39,28 +39,18 @@ public:
|
||||
|
||||
// Throughout, uint32_t aChunk refers only to the chunk number. Chunk data is
|
||||
// stored in the Prefix structures.
|
||||
nsresult NewAddChunk(uint32_t aChunk) {
|
||||
return mAddChunks.Set(aChunk);
|
||||
} NS_WARN_UNUSED_RESULT;
|
||||
nsresult NewSubChunk(uint32_t aChunk) {
|
||||
return mSubChunks.Set(aChunk);
|
||||
} NS_WARN_UNUSED_RESULT;
|
||||
nsresult NewAddExpiration(uint32_t aChunk) {
|
||||
return mAddExpirations.Set(aChunk);
|
||||
} NS_WARN_UNUSED_RESULT;
|
||||
nsresult NewSubExpiration(uint32_t aChunk) {
|
||||
return mSubExpirations.Set(aChunk);
|
||||
} NS_WARN_UNUSED_RESULT;
|
||||
nsresult NewAddPrefix(uint32_t aAddChunk,
|
||||
const Prefix& aPrefix) NS_WARN_UNUSED_RESULT;
|
||||
nsresult NewSubPrefix(uint32_t aAddChunk,
|
||||
const Prefix& aPrefix,
|
||||
uint32_t aSubChunk) NS_WARN_UNUSED_RESULT;
|
||||
nsresult NewAddComplete(uint32_t aChunk,
|
||||
const Completion& aCompletion) NS_WARN_UNUSED_RESULT;
|
||||
nsresult NewSubComplete(uint32_t aAddChunk,
|
||||
const Completion& aCompletion,
|
||||
uint32_t aSubChunk) NS_WARN_UNUSED_RESULT;
|
||||
void NewAddChunk(uint32_t aChunk) { mAddChunks.Set(aChunk); }
|
||||
void NewSubChunk(uint32_t aChunk) { mSubChunks.Set(aChunk); }
|
||||
|
||||
void NewAddExpiration(uint32_t aChunk) { mAddExpirations.Set(aChunk); }
|
||||
void NewSubExpiration(uint32_t aChunk) { mSubExpirations.Set(aChunk); }
|
||||
|
||||
void NewAddPrefix(uint32_t aAddChunk, const Prefix& aPrefix);
|
||||
void NewSubPrefix(uint32_t aAddChunk, const Prefix& aPrefix, uint32_t aSubChunk);
|
||||
|
||||
void NewAddComplete(uint32_t aChunk, const Completion& aCompletion);
|
||||
void NewSubComplete(uint32_t aAddChunk, const Completion& aCompletion,
|
||||
uint32_t aSubChunk);
|
||||
void SetLocalUpdate(void) { mLocalUpdate = true; }
|
||||
bool IsLocalUpdate(void) { return mLocalUpdate; }
|
||||
|
||||
|
@ -27,8 +27,6 @@ namespace safebrowsing {
|
||||
|
||||
// Updates will fail if fed chunks larger than this
|
||||
const uint32_t MAX_CHUNK_SIZE = (1024 * 1024);
|
||||
// Updates will fail if the total number of touched chunks is larger than this
|
||||
const uint32_t MAX_CHUNK_RANGE = 1000000;
|
||||
|
||||
const uint32_t DOMAIN_SIZE = 4;
|
||||
|
||||
@ -173,20 +171,11 @@ ProtocolParser::ProcessExpirations(const nsCString& aLine)
|
||||
while (begin != end) {
|
||||
uint32_t first, last;
|
||||
if (ParseChunkRange(begin, end, &first, &last)) {
|
||||
if (last < first) return NS_ERROR_FAILURE;
|
||||
if (last - first > MAX_CHUNK_RANGE) return NS_ERROR_FAILURE;
|
||||
for (uint32_t num = first; num <= last; num++) {
|
||||
if (aLine[0] == 'a') {
|
||||
nsresult rv = mTableUpdate->NewAddExpiration(num);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
} else {
|
||||
nsresult rv = mTableUpdate->NewSubExpiration(num);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
if (aLine[0] == 'a')
|
||||
mTableUpdate->NewAddExpiration(num);
|
||||
else
|
||||
mTableUpdate->NewSubExpiration(num);
|
||||
}
|
||||
} else {
|
||||
return NS_ERROR_FAILURE;
|
||||
@ -237,31 +226,18 @@ ProtocolParser::ProcessChunkControl(const nsCString& aLine)
|
||||
LOG(("Processing digest256 data"));
|
||||
mChunkState.type = (command == 'a') ? CHUNK_ADD_DIGEST : CHUNK_SUB_DIGEST;
|
||||
}
|
||||
nsresult rv;
|
||||
switch (mChunkState.type) {
|
||||
case CHUNK_ADD:
|
||||
rv = mTableUpdate->NewAddChunk(mChunkState.num);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
mTableUpdate->NewAddChunk(mChunkState.num);
|
||||
break;
|
||||
case CHUNK_SUB:
|
||||
rv = mTableUpdate->NewSubChunk(mChunkState.num);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
mTableUpdate->NewSubChunk(mChunkState.num);
|
||||
break;
|
||||
case CHUNK_ADD_DIGEST:
|
||||
rv = mTableUpdate->NewAddChunk(mChunkState.num);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
mTableUpdate->NewAddChunk(mChunkState.num);
|
||||
break;
|
||||
case CHUNK_SUB_DIGEST:
|
||||
rv = mTableUpdate->NewSubChunk(mChunkState.num);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
mTableUpdate->NewSubChunk(mChunkState.num);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -347,18 +323,12 @@ ProtocolParser::ProcessPlaintextChunk(const nsACString& aChunk)
|
||||
if (mChunkState.hashSize == COMPLETE_SIZE) {
|
||||
Completion hash;
|
||||
hash.FromPlaintext(line, mCryptoHash);
|
||||
nsresult rv = mTableUpdate->NewAddComplete(mChunkState.num, hash);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
mTableUpdate->NewAddComplete(mChunkState.num, hash);
|
||||
} else {
|
||||
NS_ASSERTION(mChunkState.hashSize == 4, "Only 32- or 4-byte hashes can be used for add chunks.");
|
||||
Prefix hash;
|
||||
hash.FromPlaintext(line, mCryptoHash);
|
||||
nsresult rv = mTableUpdate->NewAddPrefix(mChunkState.num, hash);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
mTableUpdate->NewAddPrefix(mChunkState.num, hash);
|
||||
}
|
||||
} else {
|
||||
nsCString::const_iterator begin, iter, end;
|
||||
@ -376,18 +346,12 @@ ProtocolParser::ProcessPlaintextChunk(const nsACString& aChunk)
|
||||
if (mChunkState.hashSize == COMPLETE_SIZE) {
|
||||
Completion hash;
|
||||
hash.FromPlaintext(Substring(iter, end), mCryptoHash);
|
||||
nsresult rv = mTableUpdate->NewSubComplete(addChunk, hash, mChunkState.num);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
mTableUpdate->NewSubComplete(addChunk, hash, mChunkState.num);
|
||||
} else {
|
||||
NS_ASSERTION(mChunkState.hashSize == 4, "Only 32- or 4-byte hashes can be used for add chunks.");
|
||||
Prefix hash;
|
||||
hash.FromPlaintext(Substring(iter, end), mCryptoHash);
|
||||
nsresult rv = mTableUpdate->NewSubPrefix(addChunk, hash, mChunkState.num);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
mTableUpdate->NewSubPrefix(addChunk, hash, mChunkState.num);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -454,10 +418,7 @@ ProtocolParser::ProcessDigestAdd(const nsACString& aChunk)
|
||||
Completion hash;
|
||||
hash.Assign(Substring(aChunk, start, COMPLETE_SIZE));
|
||||
start += COMPLETE_SIZE;
|
||||
nsresult rv = mTableUpdate->NewAddComplete(mChunkState.num, hash);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
mTableUpdate->NewAddComplete(mChunkState.num, hash);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
@ -484,10 +445,7 @@ ProtocolParser::ProcessDigestSub(const nsACString& aChunk)
|
||||
hash.Assign(Substring(aChunk, start, COMPLETE_SIZE));
|
||||
start += COMPLETE_SIZE;
|
||||
|
||||
nsresult rv = mTableUpdate->NewSubComplete(addChunk, hash, mChunkState.num);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
mTableUpdate->NewSubComplete(addChunk, hash, mChunkState.num);
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
@ -500,10 +458,7 @@ ProtocolParser::ProcessHostAdd(const Prefix& aDomain, uint8_t aNumEntries,
|
||||
"ProcessHostAdd should only be called for prefix hashes.");
|
||||
|
||||
if (aNumEntries == 0) {
|
||||
nsresult rv = mTableUpdate->NewAddPrefix(mChunkState.num, aDomain);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
mTableUpdate->NewAddPrefix(mChunkState.num, aDomain);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -515,10 +470,7 @@ ProtocolParser::ProcessHostAdd(const Prefix& aDomain, uint8_t aNumEntries,
|
||||
for (uint8_t i = 0; i < aNumEntries; i++) {
|
||||
Prefix hash;
|
||||
hash.Assign(Substring(aChunk, *aStart, PREFIX_SIZE));
|
||||
nsresult rv = mTableUpdate->NewAddPrefix(mChunkState.num, hash);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
mTableUpdate->NewAddPrefix(mChunkState.num, hash);
|
||||
*aStart += PREFIX_SIZE;
|
||||
}
|
||||
|
||||
@ -545,10 +497,7 @@ ProtocolParser::ProcessHostSub(const Prefix& aDomain, uint8_t aNumEntries,
|
||||
memcpy(&addChunk, addChunkStr.BeginReading(), 4);
|
||||
addChunk = PR_ntohl(addChunk);
|
||||
|
||||
nsresult rv = mTableUpdate->NewSubPrefix(addChunk, aDomain, mChunkState.num);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
mTableUpdate->NewSubPrefix(addChunk, aDomain, mChunkState.num);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -569,10 +518,7 @@ ProtocolParser::ProcessHostSub(const Prefix& aDomain, uint8_t aNumEntries,
|
||||
prefix.Assign(Substring(aChunk, *aStart, PREFIX_SIZE));
|
||||
*aStart += PREFIX_SIZE;
|
||||
|
||||
nsresult rv = mTableUpdate->NewSubPrefix(addChunk, prefix, mChunkState.num);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
mTableUpdate->NewSubPrefix(addChunk, prefix, mChunkState.num);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
@ -600,10 +546,7 @@ ProtocolParser::ProcessHostAddComplete(uint8_t aNumEntries,
|
||||
for (uint8_t i = 0; i < aNumEntries; i++) {
|
||||
Completion hash;
|
||||
hash.Assign(Substring(aChunk, *aStart, COMPLETE_SIZE));
|
||||
nsresult rv = mTableUpdate->NewAddComplete(mChunkState.num, hash);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
mTableUpdate->NewAddComplete(mChunkState.num, hash);
|
||||
*aStart += COMPLETE_SIZE;
|
||||
}
|
||||
|
||||
@ -640,10 +583,7 @@ ProtocolParser::ProcessHostSubComplete(uint8_t aNumEntries,
|
||||
memcpy(&addChunk, addChunkStr.BeginReading(), 4);
|
||||
addChunk = PR_ntohl(addChunk);
|
||||
|
||||
nsresult rv = mTableUpdate->NewSubComplete(addChunk, hash, mChunkState.num);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
mTableUpdate->NewSubComplete(addChunk, hash, mChunkState.num);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
@ -669,17 +669,9 @@ nsUrlClassifierDBServiceWorker::CacheCompletions(CacheResultArray *results)
|
||||
TableUpdate * tu = pParse->GetTableUpdate(resultsPtr->ElementAt(i).table);
|
||||
LOG(("CacheCompletion Addchunk %d hash %X", resultsPtr->ElementAt(i).entry.addChunk,
|
||||
resultsPtr->ElementAt(i).entry.ToUint32()));
|
||||
rv = tu->NewAddComplete(resultsPtr->ElementAt(i).entry.addChunk,
|
||||
resultsPtr->ElementAt(i).entry.complete);
|
||||
if (NS_FAILED(rv)) {
|
||||
// We can bail without leaking here because ForgetTableUpdates
|
||||
// hasn't been called yet.
|
||||
return rv;
|
||||
}
|
||||
rv = tu->NewAddChunk(resultsPtr->ElementAt(i).entry.addChunk);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
tu->NewAddComplete(resultsPtr->ElementAt(i).entry.addChunk,
|
||||
resultsPtr->ElementAt(i).entry.complete);
|
||||
tu->NewAddChunk(resultsPtr->ElementAt(i).entry.addChunk);
|
||||
tu->SetLocalUpdate();
|
||||
updates.AppendElement(tu);
|
||||
pParse->ForgetTableUpdates();
|
||||
|
Loading…
Reference in New Issue
Block a user