Better error for _EnterBstrWrapped on allocated (indef) strings (#221)
Better error for QCBORDecode_EnterBstrWrapped on allocated strings. Since indefinite-length strings are always allocated, this gives a better error for attempts to use this on indefinite-length strings.
The TODO: to make this work is closed out as it was decided not to support QCBORDecode_EnterBstrWrapped() on indefinite-length strings. To do so would require increasing the size of QCBORItem.
* Add limitations comment
---------
Co-authored-by: Laurence Lundblade <lgl@securitytheory.com>
diff --git a/test/qcbor_decode_tests.c b/test/qcbor_decode_tests.c
index 7b3b0f3..7fedf91 100644
--- a/test/qcbor_decode_tests.c
+++ b/test/qcbor_decode_tests.c
@@ -8642,16 +8642,14 @@
QCBORDecode_EnterArray(&DCtx, NULL);
QCBORDecode_EnterBstrWrapped(&DCtx, 2, NULL);
- if(QCBORDecode_GetError(&DCtx) != QCBOR_ERR_INPUT_TOO_LARGE) {
- /* TODO: This is what happens when trying to enter
- * indefinite-length byte string wrapped CBOR. Tolerate for
- * now. Eventually it needs to be fixed so this works, but that
- * is not simple.
- */
+ if(QCBORDecode_GetError(&DCtx) != QCBOR_ERR_CANNOT_ENTER_ALLOCATED_STRING) {
return 7300;
}
/*
+ Improvement: Fix QCBORDecode_EnterBstrWrapped() so it can work on
+ allocated strings. This is a fairly big job because of all the
+ UsefulBuf internal book keeping that needs tweaking.
QCBORDecode_GetUInt64(&DCtx, &i);
if(i != 42) {
return 7110;
@@ -8660,7 +8658,8 @@
QCBORDecode_GetUInt64(&DCtx, &i);
if(i != 42) {
return 7220;
- }*/
+ }
+ */
#endif /* QCBOR_DISABLE_INDEFINITE_LENGTH_STRINGS */