Closed Bug 1312323 Opened 9 years ago Closed 9 years ago

Single encoded value (either prefix or removal index) is not handled well

Categories

(Toolkit :: Safe Browsing, defect, P1)

defect

Tracking

()

RESOLVED FIXED
mozilla52
Tracking Status
firefox52 --- fixed

People

(Reporter: hchang, Assigned: hchang)

References

Details

(Whiteboard: #sbv4-m2)

Attachments

(2 files)

According to [1], if there is only one value encoded, num_entries will be zero and rice_parameter will be missing. We need to take this special case into account. Besides, we'd better bubble the decoding error up so that no invalid update would be attempted to apply. [1] https://dxr.mozilla.org/mozilla-central/source/toolkit/components/url-classifier/chromium/safebrowsing.proto#419
Assignee: nobody → hchang
BTW, this bug is the root cause of Bug 1309770: "When any of the updates contains "single encoded value" (either addition or removal), the update would fail because the single-value addition or removal will not be applied." And the reason we bubble the decoding error up (changes in ProtocolParserProtobuf::ProcessOneResponse) is to prevent the junk TableUpdate from being applied. Note that the usage of RiceDeltaDecoder is slightly modified to accommodate the "single value" case and make the code simpler and cleaner.
The attachment is an instance which contains a "single encoded value" update.
Comment on attachment 8803775 [details] Bug 1312323 - Consider the "single encoded value" case and bubble the decoding error up. . https://reviewboard.mozilla.org/r/87926/#review87388 Looks good. I only have a nit for a comment and a suggestion for a stronger check before you land this. ::: toolkit/components/url-classifier/ProtocolParser.cpp (Diff revision 3) > DoRiceDeltaDecode(const RiceDeltaEncoding& aEncoding, > nsTArray<uint32_t>& aDecoded) > { > - // Sanity check of the encoding info. > + if (!aEncoding.has_first_value()) { > - if (!aEncoding.has_first_value() || > - !aEncoding.has_rice_parameter() || Maybe we should expand that check to ensure that either: 1. `!has_num_entries()`, or 2. `has_num_entries() && has_rice_parameters() && has_encoded_data()` That way we would essentially assert on our understanding of the spec. ::: toolkit/components/url-classifier/tests/gtest/TestProtocolParser.cpp:96 (Diff revision 3) > + > + auto& tus = p->GetTableUpdates(); > + auto tuv4 = TableUpdate::Cast<TableUpdateV4>(tus[0]); > + auto& prefixMap = tuv4->Prefixes(); > + for (auto iter = prefixMap.Iter(); !iter.Done(); iter.Next()) { > + // This prefix map should contain only 4-byte prefixes. "only a single 4-byte prefix"
Attachment #8803775 - Flags: review?(francois) → review+
Status: NEW → ASSIGNED
Priority: -- → P1
Whiteboard: #sbv4-m2
Pushed by hchang@mozilla.com: https://hg.mozilla.org/integration/mozilla-inbound/rev/d26ac63f1b81 Consider the "single encoded value" case and bubble the decoding error up. r=francois.
Status: ASSIGNED → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla52
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: