Skip to content

Commit c737428

Browse files
laurencelundbladeLaurence Lundblade
andauthored
Defensive handling of reserved values in additional info (#249)
This restores the defensive handling of reserved values (28, 29, 30) in additional info in the CBOR head that was present in QCBOR 1.3. There are no problems or test failures in 1.4, but this fix should be picked up. The change is to put the QCBORItem initialization back in the right place. From analysis of the code, the only effect was when the header decode returned QCBOR_ERR_UNSUPPORTED, a recoverable error. It is assumed that no caller would examine the secondary fields of QCBORItem when this error occurs, so there's no issue. * Update version indicators to 1.4 * initialization fix --------- Co-authored-by: Laurence Lundblade <[email protected]>
1 parent 6837bbf commit c737428

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/qcbor_decode.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1323,9 +1323,11 @@ QCBOR_Private_DecodeAtomicDataItem(QCBORDecodeContext *pMe,
13231323
QCBORItem *pDecodedItem)
13241324
{
13251325
QCBORError uReturn;
1326-
int nMajorType = 0;
1327-
uint64_t uArgument = 0;
1328-
int nAdditionalInfo = 0;
1326+
int nMajorType = 0;
1327+
uint64_t uArgument = 0;
1328+
int nAdditionalInfo = 0;
1329+
1330+
memset(pDecodedItem, 0, sizeof(QCBORItem));
13291331

13301332
/* Decode the "head" that every CBOR item has into the major type,
13311333
* argument and the additional info.
@@ -1335,8 +1337,6 @@ QCBOR_Private_DecodeAtomicDataItem(QCBORDecodeContext *pMe,
13351337
return uReturn;
13361338
}
13371339

1338-
memset(pDecodedItem, 0, sizeof(QCBORItem));
1339-
13401340
/* All the functions below get inlined by the optimizer. This code
13411341
* is easier to read with them all being similar functions, even if
13421342
* some functions don't do much.

0 commit comments

Comments
 (0)