final clean up
diff --git a/inc/qcbor/qcbor_common.h b/inc/qcbor/qcbor_common.h
index 04fb3c9..1ebfb7b 100644
--- a/inc/qcbor/qcbor_common.h
+++ b/inc/qcbor/qcbor_common.h
@@ -31,6 +31,7 @@
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* ========================================================================= */
+
#ifndef qcbor_common_h
#define qcbor_common_h
@@ -368,10 +369,9 @@
QCBOR_ERR_ARRAY_DECODE_NESTING_TOO_DEEP = 41,
/** During decoding, the array or map had too many items in it.
- * This limit @ref QCBOR_MAX_ITEMS_IN_ARRAY, typically 65,534,
- * UINT16_MAX - 1. This error makes no further decoding
- * possible. */
- // TODO: ..IN_MAP.
+ * This limit is @ref QCBOR_MAX_ITEMS_IN_ARRAY (65,534) for
+ * arrays and @ref QCBOR_MAX_ITEMS_IN_MAP (32,767) for maps. This
+ * error makes no further decoding possible. */
QCBOR_ERR_ARRAY_DECODE_TOO_LONG = 42,
/** When decoding, a string's size is greater than what a size_t
diff --git a/src/qcbor_decode.c b/src/qcbor_decode.c
index 0107a5b..0d689d8 100644
--- a/src/qcbor_decode.c
+++ b/src/qcbor_decode.c
@@ -1037,7 +1037,7 @@
static QCBORError
QCBOR_Private_DecodeArrayOrMap(const uint8_t uMode,
const int nMajorType,
- uint64_t uItemCount,
+ uint64_t uItemCount,
const int nAdditionalInfo,
QCBORItem *pDecodedItem)
{
@@ -1073,17 +1073,18 @@
/* ----- Definite-length array/map ----- */
if(uItemCount > (nMajorType == QCBOR_TYPE_MAP ? QCBOR_MAX_ITEMS_IN_MAP : QCBOR_MAX_ITEMS_IN_ARRAY)) {
uReturn = QCBOR_ERR_ARRAY_DECODE_TOO_LONG;
- }
+ } else {
#ifndef QCBOR_DISABLE_NON_INTEGER_LABELS
- if(uMode == QCBOR_DECODE_MODE_MAP_AS_ARRAY && nMajorType == QCBOR_TYPE_MAP) {
- /* ------ Map as array ------ */
- uItemCount *= 2;
- }
+ if(uMode == QCBOR_DECODE_MODE_MAP_AS_ARRAY && nMajorType == QCBOR_TYPE_MAP) {
+ /* ------ Map as array ------ */
+ uItemCount *= 2;
+ }
#endif /* ! QCBOR_DISABLE_NON_INTEGER_LABELS */
- /* cast OK because of check above */
- pDecodedItem->val.uCount = (uint16_t)uItemCount;
+ /* cast OK because of check above */
+ pDecodedItem->val.uCount = (uint16_t)uItemCount;
+ }
}
return uReturn;
diff --git a/test/qcbor_decode_tests.c b/test/qcbor_decode_tests.c
index aa52c53..9f16668 100644
--- a/test/qcbor_decode_tests.c
+++ b/test/qcbor_decode_tests.c
@@ -2310,7 +2310,7 @@
0xb9, 0x7f, 0xff};
static const uint8_t spTooLargeMapFake[] = {
- 0xba, 0x00, 0x01, 0x00, 0x00};
+ 0xba, 0x00, 0x00, 0x80, 0x00};
int32_t ParseMapTest(void)