Handle zero-length chunks in indefinite-length strings
Previously this would generate a QCBOR_ERR_STRING_ALLOCATE error. There is no security issue or attack vector here. QCBOR just errored out on a zero-length string chunk when it should not have. Zero-length string chunks are explicitly allowed in RFC 8949
Thanks David for the catch and the fix!
* Fix decoding of an indefinite-length string with a zero-length first chunk. (#134)
Signed-off-by: David Navarro <david.navarro@ioterop.com>
* Add an unit test for #134.
Signed-off-by: David Navarro <david.navarro@ioterop.com>
Co-authored-by: David Navarro <david.navarro@ioterop.com>
diff --git a/test/run_tests.c b/test/run_tests.c
index be2582f..a5c6635 100644
--- a/test/run_tests.c
+++ b/test/run_tests.c
@@ -111,6 +111,7 @@
TEST_ENTRY(IndefiniteLengthStringTest),
TEST_ENTRY(SpiffyIndefiniteLengthStringsTests),
TEST_ENTRY(SetUpAllocatorTest),
+ TEST_ENTRY(CBORTestIssue134),
#endif /* #ifndef QCBOR_DISABLE_INDEFINITE_LENGTH_STRINGS */
#ifndef QCBOR_DISABLE_PREFERRED_FLOAT
TEST_ENTRY(HalfPrecisionDecodeBasicTests),