Reject reserved values and indefinite lengths
RFC 8949 defines additional information values 28, 29, 30 and 31 as
either reserved or indicating indefinite length values. Reject all of
these.
Test: cppbor_host_test_external
Change-Id: Ic9ae7630c8f75d060e4199d375c1f696699a4f66
diff --git a/src/cppbor_parse.cpp b/src/cppbor_parse.cpp
index 5cf76b2..fcf0dac 100644
--- a/src/cppbor_parse.cpp
+++ b/src/cppbor_parse.cpp
@@ -202,8 +202,13 @@
bool success = true;
uint64_t addlData;
- if (tagInt < ONE_BYTE_LENGTH || tagInt > EIGHT_BYTE_LENGTH) {
+ if (tagInt < ONE_BYTE_LENGTH) {
addlData = tagInt;
+ } else if (tagInt > EIGHT_BYTE_LENGTH) {
+ parseClient->error(
+ begin,
+ "Reserved additional information value or unsupported indefinite length item.");
+ return {begin, nullptr};
} else {
switch (tagInt) {
case ONE_BYTE_LENGTH: