Turn up compiler warnings to max and fix them; one more indefinite length test
diff --git a/test/qcbor_decode_tests.c b/test/qcbor_decode_tests.c
index 25ab721..9bdfe79 100644
--- a/test/qcbor_decode_tests.c
+++ b/test/qcbor_decode_tests.c
@@ -69,7 +69,7 @@
printf("%s ", szLabel);
}
- int i;
+ size_t i;
for(i = 0; i < nLen; i++) {
uint8_t Z = pEncoded[i];
printf("%02x ", Z);
@@ -132,31 +132,31 @@
if((nCBORError = QCBORDecode_GetNext(pDCtx, &Item)))
return nCBORError;
if(Item.uDataType != QCBOR_TYPE_INT64 || // Todo; fix this for 32-bit machines
- Item.val.uint64 != -9223372036854775807LL - 1)
+ Item.val.int64 != -9223372036854775807LL - 1)
return -1;
if((nCBORError = QCBORDecode_GetNext(pDCtx, &Item)))
return nCBORError;
if(Item.uDataType != QCBOR_TYPE_INT64 ||
- Item.val.uint64 != -4294967297)
+ Item.val.int64 != -4294967297)
return -1;
if((nCBORError = QCBORDecode_GetNext(pDCtx, &Item)))
return nCBORError;
if(Item.uDataType != QCBOR_TYPE_INT64 ||
- Item.val.uint64 != -4294967296)
+ Item.val.int64 != -4294967296)
return -1;
if((nCBORError = QCBORDecode_GetNext(pDCtx, &Item)))
return nCBORError;
if(Item.uDataType != QCBOR_TYPE_INT64 ||
- Item.val.uint64 != -4294967295)
+ Item.val.int64 != -4294967295)
return -1;
if((nCBORError = QCBORDecode_GetNext(pDCtx, &Item)))
return nCBORError;
if(Item.uDataType != QCBOR_TYPE_INT64 ||
- Item.val.uint64 != -4294967294)
+ Item.val.int64 != -4294967294)
return -1;
@@ -1501,7 +1501,7 @@
if(Item.uLabelType == QCBOR_TYPE_INT64) {
if(Item.label.int64 != nLabel) return -1;
} else {
- if(Item.label.uint64 != nLabel) return -1;
+ if(Item.label.uint64 != (uint64_t)nLabel) return -1;
}
}
if(Item.uNestingLevel != uNestingLevel) return -1;
@@ -1650,6 +1650,7 @@
static const uint8_t pIndefiniteArrayBad1[] = {0x9f}; // No closing break
static const uint8_t pIndefiniteArrayBad2[] = {0x9f, 0x9f, 0x02, 0xff}; // Not enough closing breaks
static const uint8_t pIndefiniteArrayBad3[] = {0x9f, 0x02, 0xff, 0xff}; // Too many closing breaks
+static const uint8_t pIndefiniteArrayBad4[] = {0x81, 0x9f}; // Unclosed indeflen inside def len
int indefinite_length_decode_test()
@@ -1708,7 +1709,7 @@
return -1;
}
- nResult = QCBORDecode_Finish(&DC); // TODO: find bug related to this
+ nResult = QCBORDecode_Finish(&DC);
if(nResult != QCBOR_ERR_HIT_END) {
return -2;
}
@@ -1764,6 +1765,29 @@
return -2;
}
+
+ // --- next test -----
+ IndefLen = UsefulBuf_FromByteArrayLiteral(pIndefiniteArrayBad4);
+
+ QCBORDecode_Init(&DC, IndefLen, QCBOR_DECODE_MODE_NORMAL);
+
+ QCBORDecode_SetMemPool(&DC, MemPool, false);
+
+ nResult = QCBORDecode_GetNext(&DC, &Item);
+ if(nResult || Item.uDataType != QCBOR_TYPE_ARRAY) {
+ return -1;
+ }
+
+ nResult = QCBORDecode_GetNext(&DC, &Item);
+ if(nResult || Item.uDataType != QCBOR_TYPE_ARRAY) {
+ return -1;
+ }
+
+ nResult = QCBORDecode_Finish(&DC);
+ if(nResult != QCBOR_ERR_HIT_END) {
+ return -2;
+ }
+
return 0;
}