Bug 406621: fix an off-by-one error reading chunks during safebrowsing updates. r=tony, a=dsicore

This commit is contained in:
dcamp%mozilla.com 2007-12-04 05:49:11 +00:00
Родитель 5e25aa6897
Коммит 6c5dd08bf8
1 изменённых файлов: 3 добавлений и 4 удалений

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

@ -1285,7 +1285,7 @@ nsUrlClassifierDBServiceWorker::GetChunkEntries(const nsACString& table,
// fragment
entry->AddFragment(entry->mKey, chunkNum);
} else {
if (start + (numEntries * KEY_LENGTH) >= chunk.Length()) {
if (start + (numEntries * KEY_LENGTH) > chunk.Length()) {
// there isn't as much data as they said there would be.
return NS_ERROR_FAILURE;
}
@ -1689,9 +1689,8 @@ nsUrlClassifierDBServiceWorker::ProcessChunk(PRBool* done)
LOG(("Handling a chunk sized %d", chunk.Length()));
nsTArray<nsUrlClassifierEntry> entries;
GetChunkEntries(mUpdateTable, mUpdateTableId, mChunkNum, chunk, entries);
nsresult rv;
nsresult rv = GetChunkEntries(mUpdateTable, mUpdateTableId, mChunkNum, chunk, entries);
NS_ENSURE_SUCCESS(rv, rv);
if (mChunkType == CHUNK_ADD) {
rv = AddChunk(mUpdateTableId, mChunkNum, entries);