Commit bdc2b690 authored by Adam Langley's avatar Adam Langley

cbor: document some range bounds.

It took me a little while to figure out why the bounds in this function
were valid so I added some comments.

Change-Id: I1244b966dbb6b7984dfc4fbceaa7ed6a2f369aa3
Reviewed-on: https://chromium-review.googlesource.com/984958Reviewed-by: default avatarBalazs Engedy <engedy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#548427}
parent ff7acdec
......@@ -225,12 +225,16 @@ base::Optional<CBORValue> CBORReader::DecodeValueToUnsigned(uint64_t value) {
base::Optional<CBORValue> CBORReader::DecodeToSimpleValue(
const DataItemHeader& header) {
// ReadVariadicLengthInteger provides this bound.
CHECK_LE(header.additional_info, 27);
// Floating point numbers are not supported.
if (header.additional_info > 24 && header.additional_info < 28) {
if (header.additional_info > 24) {
error_code_ = DecoderError::UNSUPPORTED_FLOATING_POINT_VALUE;
return base::nullopt;
}
// Since |header.additional_info| <= 24, ReadVariadicLengthInteger also
// provides this bound for |header.value|.
CHECK_LE(header.value, 255u);
CBORValue::SimpleValue possibly_unsupported_simple_value =
static_cast<CBORValue::SimpleValue>(static_cast<int>(header.value));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment