fix some of the failing tests
diff --git a/QCBOR.xcodeproj/project.pbxproj b/QCBOR.xcodeproj/project.pbxproj
index 9733eb7..783af79 100644
--- a/QCBOR.xcodeproj/project.pbxproj
+++ b/QCBOR.xcodeproj/project.pbxproj
@@ -69,6 +69,19 @@
E7FDBF0E256C969D007138A8 /* cmd_line_main.c in Sources */ = {isa = PBXBuildFile; fileRef = E776E096214AE0C700E67947 /* cmd_line_main.c */; };
E7FDBF0F256C969D007138A8 /* example.c in Sources */ = {isa = PBXBuildFile; fileRef = E743D0E124AC516D0017899F /* example.c */; };
E7FDBF10256C969D007138A8 /* UsefulBuf_Tests.c in Sources */ = {isa = PBXBuildFile; fileRef = 0FA9BEBC216DE31700BA646B /* UsefulBuf_Tests.c */; };
+ E7FDBF1A257A6C1F007138A8 /* qcbor_encode.c in Sources */ = {isa = PBXBuildFile; fileRef = E776E08C214AE07400E67947 /* qcbor_encode.c */; };
+ E7FDBF1B257A6C1F007138A8 /* ieee754.c in Sources */ = {isa = PBXBuildFile; fileRef = E73B57582161CA690080D658 /* ieee754.c */; };
+ E7FDBF1C257A6C1F007138A8 /* qcbor_err_to_str.c in Sources */ = {isa = PBXBuildFile; fileRef = E7864765252CE63100A0C11B /* qcbor_err_to_str.c */; };
+ E7FDBF1D257A6C1F007138A8 /* half_to_double_from_rfc7049.c in Sources */ = {isa = PBXBuildFile; fileRef = E73B575D2161CA7C0080D658 /* half_to_double_from_rfc7049.c */; };
+ E7FDBF1E257A6C1F007138A8 /* run_tests.c in Sources */ = {isa = PBXBuildFile; fileRef = E73B57632161F8F70080D658 /* run_tests.c */; };
+ E7FDBF1F257A6C1F007138A8 /* qcbor_decode.c in Sources */ = {isa = PBXBuildFile; fileRef = E776E08E214AE07500E67947 /* qcbor_decode.c */; };
+ E7FDBF20257A6C1F007138A8 /* float_tests.c in Sources */ = {isa = PBXBuildFile; fileRef = E73B575A2161CA7C0080D658 /* float_tests.c */; };
+ E7FDBF21257A6C1F007138A8 /* qcbor_decode_tests.c in Sources */ = {isa = PBXBuildFile; fileRef = 0FA9BEB5216CE6CA00BA646B /* qcbor_decode_tests.c */; };
+ E7FDBF22257A6C1F007138A8 /* UsefulBuf.c in Sources */ = {isa = PBXBuildFile; fileRef = E776E08D214AE07500E67947 /* UsefulBuf.c */; };
+ E7FDBF23257A6C1F007138A8 /* qcbor_encode_tests.c in Sources */ = {isa = PBXBuildFile; fileRef = 0FA9BEB8216DC7AD00BA646B /* qcbor_encode_tests.c */; };
+ E7FDBF24257A6C1F007138A8 /* cmd_line_main.c in Sources */ = {isa = PBXBuildFile; fileRef = E776E096214AE0C700E67947 /* cmd_line_main.c */; };
+ E7FDBF25257A6C1F007138A8 /* example.c in Sources */ = {isa = PBXBuildFile; fileRef = E743D0E124AC516D0017899F /* example.c */; };
+ E7FDBF26257A6C1F007138A8 /* UsefulBuf_Tests.c in Sources */ = {isa = PBXBuildFile; fileRef = 0FA9BEBC216DE31700BA646B /* UsefulBuf_Tests.c */; };
/* End PBXBuildFile section */
/* Begin PBXCopyFilesBuildPhase section */
@@ -117,6 +130,15 @@
);
runOnlyForDeploymentPostprocessing = 1;
};
+ E7FDBF28257A6C1F007138A8 /* CopyFiles */ = {
+ isa = PBXCopyFilesBuildPhase;
+ buildActionMask = 2147483647;
+ dstPath = /usr/share/man/man1/;
+ dstSubfolderSpec = 0;
+ files = (
+ );
+ runOnlyForDeploymentPostprocessing = 1;
+ };
/* End PBXCopyFilesBuildPhase section */
/* Begin PBXFileReference section */
@@ -157,6 +179,7 @@
E78C91E0240C90C100F4CECE /* qcbor_private.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 3; lastKnownFileType = sourcecode.c.h; name = qcbor_private.h; path = inc/qcbor/qcbor_private.h; sourceTree = "<group>"; tabWidth = 3; };
E78C91E1240C90C100F4CECE /* qcbor_encode.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 3; lastKnownFileType = sourcecode.c.h; name = qcbor_encode.h; path = inc/qcbor/qcbor_encode.h; sourceTree = "<group>"; tabWidth = 3; };
E7FDBF16256C969D007138A8 /* QCBOR_Disable_Indef */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = QCBOR_Disable_Indef; sourceTree = BUILT_PRODUCTS_DIR; };
+ E7FDBF2C257A6C1F007138A8 /* QCBOR_Disable_Indef_array */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = QCBOR_Disable_Indef_array; sourceTree = BUILT_PRODUCTS_DIR; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@@ -195,6 +218,13 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
+ E7FDBF27257A6C1F007138A8 /* Frameworks */ = {
+ isa = PBXFrameworksBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
@@ -230,6 +260,7 @@
E743D11B24DD4EF50017899F /* QCBOR_Disable_HW_Float */,
E743D13124DE05CC0017899F /* QCBOR_Disable_Preferred_Float */,
E7FDBF16256C969D007138A8 /* QCBOR_Disable_Indef */,
+ E7FDBF2C257A6C1F007138A8 /* QCBOR_Disable_Indef_array */,
);
name = Products;
sourceTree = "<group>";
@@ -369,6 +400,23 @@
productReference = E7FDBF16256C969D007138A8 /* QCBOR_Disable_Indef */;
productType = "com.apple.product-type.tool";
};
+ E7FDBF18257A6C1F007138A8 /* QCBOR_Disable_Indef_array */ = {
+ isa = PBXNativeTarget;
+ buildConfigurationList = E7FDBF29257A6C1F007138A8 /* Build configuration list for PBXNativeTarget "QCBOR_Disable_Indef_array" */;
+ buildPhases = (
+ E7FDBF19257A6C1F007138A8 /* Sources */,
+ E7FDBF27257A6C1F007138A8 /* Frameworks */,
+ E7FDBF28257A6C1F007138A8 /* CopyFiles */,
+ );
+ buildRules = (
+ );
+ dependencies = (
+ );
+ name = QCBOR_Disable_Indef_array;
+ productName = QCBOR;
+ productReference = E7FDBF2C257A6C1F007138A8 /* QCBOR_Disable_Indef_array */;
+ productType = "com.apple.product-type.tool";
+ };
/* End PBXNativeTarget section */
/* Begin PBXProject section */
@@ -401,6 +449,7 @@
E743D10924DD4EF50017899F /* QCBOR_Disable_HW_Float */,
E743D11E24DE05CC0017899F /* QCBOR_Disable_Preferred_Float */,
E7FDBF02256C969D007138A8 /* QCBOR_Disable_Indef */,
+ E7FDBF18257A6C1F007138A8 /* QCBOR_Disable_Indef_array */,
);
};
/* End PBXProject section */
@@ -503,6 +552,26 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
+ E7FDBF19257A6C1F007138A8 /* Sources */ = {
+ isa = PBXSourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ E7FDBF1A257A6C1F007138A8 /* qcbor_encode.c in Sources */,
+ E7FDBF1B257A6C1F007138A8 /* ieee754.c in Sources */,
+ E7FDBF1C257A6C1F007138A8 /* qcbor_err_to_str.c in Sources */,
+ E7FDBF1D257A6C1F007138A8 /* half_to_double_from_rfc7049.c in Sources */,
+ E7FDBF1E257A6C1F007138A8 /* run_tests.c in Sources */,
+ E7FDBF1F257A6C1F007138A8 /* qcbor_decode.c in Sources */,
+ E7FDBF20257A6C1F007138A8 /* float_tests.c in Sources */,
+ E7FDBF21257A6C1F007138A8 /* qcbor_decode_tests.c in Sources */,
+ E7FDBF22257A6C1F007138A8 /* UsefulBuf.c in Sources */,
+ E7FDBF23257A6C1F007138A8 /* qcbor_encode_tests.c in Sources */,
+ E7FDBF24257A6C1F007138A8 /* cmd_line_main.c in Sources */,
+ E7FDBF25257A6C1F007138A8 /* example.c in Sources */,
+ E7FDBF26257A6C1F007138A8 /* UsefulBuf_Tests.c in Sources */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
/* End PBXSourcesBuildPhase section */
/* Begin XCBuildConfiguration section */
@@ -768,6 +837,35 @@
};
name = Release;
};
+ E7FDBF2A257A6C1F007138A8 /* Debug */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ CLANG_UNDEFINED_BEHAVIOR_SANITIZER_INTEGER = YES;
+ CLANG_UNDEFINED_BEHAVIOR_SANITIZER_NULLABILITY = YES;
+ CODE_SIGN_STYLE = Automatic;
+ GCC_OPTIMIZATION_LEVEL = 0;
+ GCC_PREPROCESSOR_DEFINITIONS = QCBOR_DISABLE_INDEFINITE_LENGTH_ARRAYS;
+ GCC_TREAT_WARNINGS_AS_ERRORS = YES;
+ GCC_WARN_PEDANTIC = YES;
+ "HEADER_SEARCH_PATHS[arch=*]" = inc;
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ };
+ name = Debug;
+ };
+ E7FDBF2B257A6C1F007138A8 /* Release */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ CLANG_UNDEFINED_BEHAVIOR_SANITIZER_INTEGER = YES;
+ CLANG_UNDEFINED_BEHAVIOR_SANITIZER_NULLABILITY = YES;
+ CODE_SIGN_STYLE = Automatic;
+ GCC_OPTIMIZATION_LEVEL = 0;
+ GCC_TREAT_WARNINGS_AS_ERRORS = YES;
+ GCC_WARN_PEDANTIC = YES;
+ "HEADER_SEARCH_PATHS[arch=*]" = inc;
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ };
+ name = Release;
+ };
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
@@ -825,6 +923,15 @@
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
+ E7FDBF29257A6C1F007138A8 /* Build configuration list for PBXNativeTarget "QCBOR_Disable_Indef_array" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ E7FDBF2A257A6C1F007138A8 /* Debug */,
+ E7FDBF2B257A6C1F007138A8 /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
+ };
/* End XCConfigurationList section */
};
rootObject = E776E074214ADF7F00E67947 /* Project object */;
diff --git a/test/qcbor_decode_tests.c b/test/qcbor_decode_tests.c
index f748104..f07a185 100644
--- a/test/qcbor_decode_tests.c
+++ b/test/qcbor_decode_tests.c
@@ -4640,8 +4640,13 @@
{ {(uint8_t[]){0xC4, 0x82, 0x1f, 0x01}, 4}, QCBOR_ERR_BAD_INT},
// 3 items in array
{ {(uint8_t[]){0xC4, 0x83, 0x03, 0x01, 02}, 5}, QCBOR_ERR_BAD_EXP_AND_MANTISSA},
+#ifndef QCBOR_DISABLE_INDEFINITE_LENGTH_ARRAYS
// unterminated indefinite length array
{ {(uint8_t[]){0xC4, 0x9f, 0x03, 0x01, 0x02}, 5}, QCBOR_ERR_BAD_EXP_AND_MANTISSA},
+#else /* QCBOR_DISABLE_INDEFINITE_LENGTH_STRINGS */
+ // unterminated indefinite length array
+ { {(uint8_t[]){0xC4, 0x9f, 0x03, 0x01, 0x02}, 5}, QCBOR_ERR_INDEF_LEN_ARRAYS_DISABLED},
+#endif /* QCBOR_DISABLE_INDEFINITE_LENGTH_STRINGS */
// Empty array
{ {(uint8_t[]){0xC4, 0x80}, 2}, QCBOR_ERR_NO_MORE_ITEMS},
// Second is not an integer
@@ -6013,6 +6018,7 @@
// Get a second item
uCBORError = QCBORDecode_GetNext(&DCtx, &Item);
+#ifndef QCBOR_DISABLE_INDEFINITE_LENGTH_ARRAYS
if(uCBORError != QCBOR_SUCCESS) {
return 9;
}
@@ -6026,6 +6032,11 @@
if(uCBORError != QCBOR_ERR_ARRAY_OR_MAP_UNCONSUMED) {
return 11;
}
+#else /* QCBOR_DISABLE_INDEFINITE_LENGTH_STRINGS */
+ if(uCBORError != QCBOR_ERR_INDEF_LEN_ARRAYS_DISABLED) {
+ return 20;
+ }
+#endif /* QCBOR_DISABLE_INDEFINITE_LENGTH_STRINGS */
// --- Sequence with a closed indefinite length array ---
@@ -6046,6 +6057,8 @@
// Get a second item
uCBORError = QCBORDecode_GetNext(&DCtx, &Item);
+#ifndef QCBOR_DISABLE_INDEFINITE_LENGTH_ARRAYS
+
if(uCBORError != QCBOR_SUCCESS) {
return 14;
}
@@ -6059,6 +6072,11 @@
if(uCBORError != QCBOR_SUCCESS) {
return 16;
}
+#else /* QCBOR_DISABLE_INDEFINITE_LENGTH_STRINGS */
+ if(uCBORError != QCBOR_ERR_INDEF_LEN_ARRAYS_DISABLED) {
+ return 20;
+ }
+#endif /* QCBOR_DISABLE_INDEFINITE_LENGTH_STRINGS */
return 0;
diff --git a/test/run_tests.c b/test/run_tests.c
index b2dc46c..2936577 100644
--- a/test/run_tests.c
+++ b/test/run_tests.c
@@ -63,8 +63,11 @@
TEST_ENTRY(EmptyMapsAndArraysTest),
TEST_ENTRY(NotWellFormedTests),
TEST_ENTRY(ParseMapAsArrayTest),
+#ifndef QCBOR_DISABLE_INDEFINITE_LENGTH_ARRAYS
TEST_ENTRY(IndefiniteLengthNestTest),
+ TEST_ENTRY(IndefiniteLengthArrayMapTest),
TEST_ENTRY(NestedMapTestIndefLen),
+#endif
TEST_ENTRY(ParseSimpleTest),
TEST_ENTRY(DecodeFailureTests),
TEST_ENTRY(EncodeRawTest),
@@ -82,7 +85,6 @@
TEST_ENTRY(ParseTooDeepArrayTest),
TEST_ENTRY(ComprehensiveInputTest),
TEST_ENTRY(ParseMapTest),
- TEST_ENTRY(IndefiniteLengthArrayMapTest),
TEST_ENTRY(BasicEncodeTest),
TEST_ENTRY(NestedMapTest),
TEST_ENTRY(BignumParseTest),