git: f55904f2f645 - stable/13 - Import libcbor at 'contrib/libcbor/'
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 09 Feb 2022 23:58:13 UTC
The branch stable/13 has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=f55904f2f645a6b19a516709fa715ec0ed7a618c commit f55904f2f645a6b19a516709fa715ec0ed7a618c Author: Ed Maste <emaste@FreeBSD.org> AuthorDate: 2021-10-07 00:26:10 +0000 Commit: Ed Maste <emaste@FreeBSD.org> CommitDate: 2022-02-09 21:23:53 +0000 Import libcbor at 'contrib/libcbor/' git-subtree-dir: contrib/libcbor git-subtree-mainline: 293663f4da9e8b8aeb106ce3b73a8ed2aa2a8a90 git-subtree-split: 5b2defbd2a1aa991bd0a2855eef8e15107572747 (cherry picked from commit 10ff414c14eef433d8157f0c17904d740693933b) --- contrib/libcbor/.clang-format | 151 ++ contrib/libcbor/.github/workflows/fuzz.yml | 23 + contrib/libcbor/.gitignore | 8 + contrib/libcbor/.travis.yml | 66 + contrib/libcbor/CHANGELOG.md | 109 + contrib/libcbor/CMakeLists.txt | 159 ++ contrib/libcbor/CMakeModules/FindCJSON.cmake | 9 + contrib/libcbor/CMakeModules/FindCMocka.cmake | 49 + contrib/libcbor/CMakeModules/LibFindMacros.cmake | 120 + contrib/libcbor/Doxyfile | 2417 ++++++++++++++++++++ contrib/libcbor/LICENSE.md | 21 + contrib/libcbor/README.md | 122 + contrib/libcbor/appveyor.yml | 27 + contrib/libcbor/clang-format.sh | 17 + contrib/libcbor/codecov.yml | 2 + contrib/libcbor/doc/Makefile | 180 ++ contrib/libcbor/doc/doxy_frontpage.md | 37 + contrib/libcbor/doc/make.bat | 242 ++ contrib/libcbor/doc/source/api.rst | 39 + contrib/libcbor/doc/source/api/decoding.rst | 53 + contrib/libcbor/doc/source/api/encoding.rst | 23 + .../doc/source/api/item_reference_counting.rst | 41 + contrib/libcbor/doc/source/api/item_types.rst | 41 + contrib/libcbor/doc/source/api/type_0_1.rst | 91 + contrib/libcbor/doc/source/api/type_2.rst | 66 + contrib/libcbor/doc/source/api/type_3.rst | 55 + contrib/libcbor/doc/source/api/type_4.rst | 62 + contrib/libcbor/doc/source/api/type_5.rst | 44 + contrib/libcbor/doc/source/api/type_6.rst | 21 + contrib/libcbor/doc/source/api/type_7.rst | 75 + contrib/libcbor/doc/source/changelog.rst | 4 + contrib/libcbor/doc/source/conf.py | 296 +++ contrib/libcbor/doc/source/development.rst | 143 ++ contrib/libcbor/doc/source/getting_started.rst | 190 ++ contrib/libcbor/doc/source/img/win_1.png | Bin 0 -> 29291 bytes contrib/libcbor/doc/source/img/win_2.png | Bin 0 -> 20179 bytes contrib/libcbor/doc/source/img/win_3.png | Bin 0 -> 47224 bytes contrib/libcbor/doc/source/img/win_4.png | Bin 0 -> 11272 bytes contrib/libcbor/doc/source/img/win_5.png | Bin 0 -> 29490 bytes contrib/libcbor/doc/source/img/win_6.png | Bin 0 -> 25195 bytes contrib/libcbor/doc/source/index.rst | 40 + contrib/libcbor/doc/source/internal.rst | 128 ++ contrib/libcbor/doc/source/requirements.txt | 39 + contrib/libcbor/doc/source/rfc_conformance.rst | 17 + contrib/libcbor/doc/source/streaming.rst | 13 + contrib/libcbor/doc/source/streaming/decoding.rst | 40 + contrib/libcbor/doc/source/streaming/encoding.rst | 4 + contrib/libcbor/doc/source/tests.rst | 39 + contrib/libcbor/doc/source/using.rst | 173 ++ contrib/libcbor/examples/CMakeLists.txt | 25 + contrib/libcbor/examples/cjson2cbor.c | 145 ++ contrib/libcbor/examples/create_items.c | 33 + contrib/libcbor/examples/data/floats.cbor | Bin 0 -> 39 bytes contrib/libcbor/examples/data/indef_string.cbor | 1 + contrib/libcbor/examples/data/integer.cbor | 1 + contrib/libcbor/examples/data/json_example.json | 6 + contrib/libcbor/examples/data/map.cbor | Bin 0 -> 26 bytes contrib/libcbor/examples/data/nested_array.cbor | 1 + contrib/libcbor/examples/data/tagged_date.cbor | 1 + contrib/libcbor/examples/hello.c | 16 + contrib/libcbor/examples/readfile.c | 78 + contrib/libcbor/examples/sort.c | 41 + contrib/libcbor/examples/streaming_parser.c | 58 + contrib/libcbor/misc/bytes.rb | 3 + contrib/libcbor/misc/file_to_bytes.rb | 5 + contrib/libcbor/misc/hooks/pre-commit | 18 + contrib/libcbor/misc/repeat.rb | 3 + contrib/libcbor/misc/seq.rb | 3 + contrib/libcbor/misc/update_version.py | 38 + contrib/libcbor/oss-fuzz/build.sh | 28 + contrib/libcbor/oss-fuzz/cbor_load_fuzzer.cc | 37 + contrib/libcbor/release.sh | 75 + contrib/libcbor/src/CMakeLists.txt | 45 + contrib/libcbor/src/allocators.c | 19 + contrib/libcbor/src/cbor.c | 345 +++ contrib/libcbor/src/cbor.h | 68 + contrib/libcbor/src/cbor/arrays.c | 135 ++ contrib/libcbor/src/cbor/arrays.h | 116 + contrib/libcbor/src/cbor/bytestrings.c | 117 + contrib/libcbor/src/cbor/bytestrings.h | 132 ++ contrib/libcbor/src/cbor/callbacks.c | 116 + contrib/libcbor/src/cbor/callbacks.h | 187 ++ contrib/libcbor/src/cbor/common.c | 160 ++ contrib/libcbor/src/cbor/common.h | 303 +++ contrib/libcbor/src/cbor/configuration.h.in | 16 + contrib/libcbor/src/cbor/data.h | 255 +++ contrib/libcbor/src/cbor/encoding.c | 192 ++ contrib/libcbor/src/cbor/encoding.h | 109 + contrib/libcbor/src/cbor/floats_ctrls.c | 189 ++ contrib/libcbor/src/cbor/floats_ctrls.h | 212 ++ .../libcbor/src/cbor/internal/builder_callbacks.c | 389 ++++ .../libcbor/src/cbor/internal/builder_callbacks.h | 81 + contrib/libcbor/src/cbor/internal/encoders.c | 98 + contrib/libcbor/src/cbor/internal/encoders.h | 36 + contrib/libcbor/src/cbor/internal/loaders.c | 80 + contrib/libcbor/src/cbor/internal/loaders.h | 36 + contrib/libcbor/src/cbor/internal/memory_utils.c | 44 + contrib/libcbor/src/cbor/internal/memory_utils.h | 39 + contrib/libcbor/src/cbor/internal/stack.c | 33 + contrib/libcbor/src/cbor/internal/stack.h | 41 + contrib/libcbor/src/cbor/internal/unicode.c | 94 + contrib/libcbor/src/cbor/internal/unicode.h | 32 + contrib/libcbor/src/cbor/ints.c | 191 ++ contrib/libcbor/src/cbor/ints.h | 210 ++ contrib/libcbor/src/cbor/maps.c | 125 + contrib/libcbor/src/cbor/maps.h | 112 + contrib/libcbor/src/cbor/serialization.c | 286 +++ contrib/libcbor/src/cbor/serialization.h | 135 ++ contrib/libcbor/src/cbor/streaming.c | 664 ++++++ contrib/libcbor/src/cbor/streaming.h | 37 + contrib/libcbor/src/cbor/strings.c | 133 ++ contrib/libcbor/src/cbor/strings.h | 153 ++ contrib/libcbor/src/cbor/tags.c | 43 + contrib/libcbor/src/cbor/tags.h | 65 + contrib/libcbor/src/libcbor.pc.in | 11 + contrib/libcbor/test/CMakeLists.txt | 29 + contrib/libcbor/test/assertions.c | 53 + contrib/libcbor/test/assertions.h | 34 + contrib/libcbor/test/bad_inputs_test.c | 121 + contrib/libcbor/test/callbacks_test.c | 40 + contrib/libcbor/test/cbor_serialize_test.c | 323 +++ contrib/libcbor/test/cbor_stream_decode_test.c | 599 +++++ contrib/libcbor/test/copy_test.c | 207 ++ contrib/libcbor/test/cpp_linkage_test.cpp | 11 + contrib/libcbor/test/data/callbacks.cbor | Bin 0 -> 79 bytes contrib/libcbor/test/data/callbacks.diag | 1 + contrib/libcbor/test/data/pretty.cbor | 3 + contrib/libcbor/test/data/pretty.diag | 1 + contrib/libcbor/test/fuzz_test.c | 87 + contrib/libcbor/test/memory_allocation_test.c | 277 +++ contrib/libcbor/test/pretty_printer_test.c | 43 + contrib/libcbor/test/stack_over_limit_test.c | 35 + contrib/libcbor/test/stream_expectations.c | 317 +++ contrib/libcbor/test/stream_expectations.h | 151 ++ contrib/libcbor/test/type_0_encoders_test.c | 74 + contrib/libcbor/test/type_0_test.c | 147 ++ contrib/libcbor/test/type_1_encoders_test.c | 75 + contrib/libcbor/test/type_1_test.c | 102 + contrib/libcbor/test/type_2_encoders_test.c | 41 + contrib/libcbor/test/type_2_test.c | 327 +++ contrib/libcbor/test/type_3_encoders_test.c | 41 + contrib/libcbor/test/type_3_test.c | 242 ++ contrib/libcbor/test/type_4_encoders_test.c | 55 + contrib/libcbor/test/type_4_test.c | 127 + contrib/libcbor/test/type_5_encoders_test.c | 40 + contrib/libcbor/test/type_5_test.c | 190 ++ contrib/libcbor/test/type_6_encoders_test.c | 35 + contrib/libcbor/test/type_6_test.c | 117 + contrib/libcbor/test/type_7_encoders_test.c | 109 + contrib/libcbor/test/type_7_test.c | 111 + contrib/libcbor/test/unicode_test.c | 41 + 151 files changed, 16202 insertions(+) diff --git a/contrib/libcbor/.clang-format b/contrib/libcbor/.clang-format new file mode 100644 index 000000000000..de0dc5e77907 --- /dev/null +++ b/contrib/libcbor/.clang-format @@ -0,0 +1,151 @@ +--- +Language: Cpp +# BasedOnStyle: Google +AccessModifierOffset: -1 +AlignAfterOpenBracket: Align +AlignConsecutiveAssignments: false +AlignConsecutiveDeclarations: false +AlignEscapedNewlines: Left +AlignOperands: true +AlignTrailingComments: true +AllowAllParametersOfDeclarationOnNextLine: true +AllowShortBlocksOnASingleLine: false +AllowShortCaseLabelsOnASingleLine: false +AllowShortFunctionsOnASingleLine: All +AllowShortIfStatementsOnASingleLine: true +AllowShortLoopsOnASingleLine: true +AlwaysBreakAfterDefinitionReturnType: None +AlwaysBreakAfterReturnType: None +AlwaysBreakBeforeMultilineStrings: true +AlwaysBreakTemplateDeclarations: true +BinPackArguments: true +BinPackParameters: true +BraceWrapping: + AfterClass: false + AfterControlStatement: false + AfterEnum: false + AfterFunction: false + AfterNamespace: false + AfterObjCDeclaration: false + AfterStruct: false + AfterUnion: false + AfterExternBlock: false + BeforeCatch: false + BeforeElse: false + IndentBraces: false + SplitEmptyFunction: true + SplitEmptyRecord: true + SplitEmptyNamespace: true +BreakBeforeBinaryOperators: None +BreakBeforeBraces: Attach +BreakBeforeInheritanceComma: false +BreakInheritanceList: BeforeColon +BreakBeforeTernaryOperators: true +BreakConstructorInitializersBeforeComma: false +BreakConstructorInitializers: BeforeColon +BreakAfterJavaFieldAnnotations: false +BreakStringLiterals: true +ColumnLimit: 80 +CommentPragmas: '^ IWYU pragma:' +CompactNamespaces: false +ConstructorInitializerAllOnOneLineOrOnePerLine: true +ConstructorInitializerIndentWidth: 4 +ContinuationIndentWidth: 4 +Cpp11BracedListStyle: true +DerivePointerAlignment: true +DisableFormat: false +ExperimentalAutoDetectBinPacking: false +FixNamespaceComments: true +ForEachMacros: + - foreach + - Q_FOREACH + - BOOST_FOREACH +IncludeBlocks: Preserve +IncludeCategories: + - Regex: '^<ext/.*\.h>' + Priority: 2 + - Regex: '^<.*\.h>' + Priority: 1 + - Regex: '^<.*' + Priority: 2 + - Regex: '.*' + Priority: 3 +IncludeIsMainRegex: '([-_](test|unittest))?$' +IndentCaseLabels: true +IndentPPDirectives: None +IndentWidth: 2 +IndentWrappedFunctionNames: false +JavaScriptQuotes: Leave +JavaScriptWrapImports: true +KeepEmptyLinesAtTheStartOfBlocks: false +MacroBlockBegin: '' +MacroBlockEnd: '' +MaxEmptyLinesToKeep: 1 +NamespaceIndentation: None +ObjCBinPackProtocolList: Never +ObjCBlockIndentWidth: 2 +ObjCSpaceAfterProperty: false +ObjCSpaceBeforeProtocolList: true +PenaltyBreakAssignment: 2 +PenaltyBreakBeforeFirstCallParameter: 1 +PenaltyBreakComment: 300 +PenaltyBreakFirstLessLess: 120 +PenaltyBreakString: 1000 +PenaltyBreakTemplateDeclaration: 10 +PenaltyExcessCharacter: 1000000 +PenaltyReturnTypeOnItsOwnLine: 200 +PointerAlignment: Left +RawStringFormats: + - Language: Cpp + Delimiters: + - cc + - CC + - cpp + - Cpp + - CPP + - 'c++' + - 'C++' + CanonicalDelimiter: '' + BasedOnStyle: google + - Language: TextProto + Delimiters: + - pb + - PB + - proto + - PROTO + EnclosingFunctions: + - EqualsProto + - EquivToProto + - PARSE_PARTIAL_TEXT_PROTO + - PARSE_TEST_PROTO + - PARSE_TEXT_PROTO + - ParseTextOrDie + - ParseTextProtoOrDie + CanonicalDelimiter: '' + BasedOnStyle: google +ReflowComments: true +SortIncludes: true +SortUsingDeclarations: true +SpaceAfterCStyleCast: false +SpaceAfterTemplateKeyword: true +SpaceBeforeAssignmentOperators: true +SpaceBeforeCpp11BracedList: false +SpaceBeforeCtorInitializerColon: true +SpaceBeforeInheritanceColon: true +SpaceBeforeParens: ControlStatements +SpaceBeforeRangeBasedForLoopColon: true +SpaceInEmptyParentheses: false +SpacesBeforeTrailingComments: 2 +SpacesInAngles: false +SpacesInContainerLiterals: true +SpacesInCStyleCastParentheses: false +SpacesInParentheses: false +SpacesInSquareBrackets: false +Standard: Auto +StatementMacros: + - Q_UNUSED + - QT_REQUIRE_VERSION +TabWidth: 8 +UseTab: Never +... + diff --git a/contrib/libcbor/.github/workflows/fuzz.yml b/contrib/libcbor/.github/workflows/fuzz.yml new file mode 100644 index 000000000000..c5275121868f --- /dev/null +++ b/contrib/libcbor/.github/workflows/fuzz.yml @@ -0,0 +1,23 @@ +name: CIFuzz +on: [pull_request] +jobs: + Fuzzing: + runs-on: ubuntu-latest + steps: + - name: Build Fuzzers + uses: google/oss-fuzz/infra/cifuzz/actions/build_fuzzers@master + with: + oss-fuzz-project-name: 'libcbor' + dry-run: false + - name: Run Fuzzers + uses: google/oss-fuzz/infra/cifuzz/actions/run_fuzzers@master + with: + oss-fuzz-project-name: 'libcbor' + fuzz-seconds: 600 + dry-run: false + - name: Upload Crash + uses: actions/upload-artifact@v1 + if: failure() + with: + name: artifacts + path: ./out/artifacts diff --git a/contrib/libcbor/.gitignore b/contrib/libcbor/.gitignore new file mode 100644 index 000000000000..b6fe00f938ad --- /dev/null +++ b/contrib/libcbor/.gitignore @@ -0,0 +1,8 @@ +build +*~ +nbproject +.idea +doxygen_docs +*/*.out +cmake-build-debug +venv diff --git a/contrib/libcbor/.travis.yml b/contrib/libcbor/.travis.yml new file mode 100644 index 000000000000..288de2903399 --- /dev/null +++ b/contrib/libcbor/.travis.yml @@ -0,0 +1,66 @@ +language: c + +matrix: + include: + - arch: amd64 + os: linux + dist: bionic + compiler: clang + env: TRAVIS_ARCH="amd64" + - arch: amd64 + os: linux + dist: bionic + compiler: gcc + env: TRAVIS_ARCH="amd64" + - arch: arm64 + os: linux + dist: bionic + compiler: gcc + env: TRAVIS_ARCH="arm64" + - arch: ppc64le + os: linux + dist: bionic + compiler: gcc + env: TRAVIS_ARCH="ppc64le" + - arch: amd64 + os: osx + compiler: gcc + env: TRAVIS_ARCH="amd64" + +before_install: + - pushd ${HOME} + - git clone https://gitlab.com/cmocka/cmocka.git + - cd cmocka && mkdir build && cd build + - cmake .. && make -j2 && sudo make install + - cd .. && popd + - if [ "$TRAVIS_OS_NAME" = "linux" ]; then sudo apt-get update -qq; sudo apt-get install -y clang-format-8 cppcheck; fi + - if [ "$TRAVIS_OS_NAME" = "linux" -a "$CC" = "gcc" -a "$TRAVIS_ARCH" = "amd64" ]; then pip install --user codecov; export CFLAGS="-coverage"; fi + +script: + - > + if [ "$TRAVIS_OS_NAME" = "linux" ]; then + cppcheck . --error-exitcode=1 + # Fail if re-formatting creates diffs (implying bad formatting) + /clang-format.sh --verbose + git diff-index --quiet HEAD + fi; + - mkdir build && cd build + - cmake -DWITH_TESTS=ON + -DCBOR_CUSTOM_ALLOC=ON + -DCMAKE_BUILD_TYPE=Debug + -DSANITIZE=OFF + .. + - make VERBOSE=1 + - ctest -VV + - ctest -T memcheck | tee memcheck.out + - > + if grep -q 'Memory Leak\|IPW\|Uninitialized Memory Conditional\|Uninitialized Memory Read' memcheck.out; then + exit 1 + fi; + + +after_success: + - if [ "$TRAVIS_OS_NAME" = "linux" -a "$CC" = "gcc" -a "$TRAVIS_ARCH" = "amd64" ]; then codecov; fi + +notifications: + email: false diff --git a/contrib/libcbor/CHANGELOG.md b/contrib/libcbor/CHANGELOG.md new file mode 100644 index 000000000000..0f13a45d6b24 --- /dev/null +++ b/contrib/libcbor/CHANGELOG.md @@ -0,0 +1,109 @@ +Next +--------------------- + +0.8.0 (2020-09-20) +--------------------- +- BUILD BREAKING: Use BUILD_SHARED_LIBS to determine how to build libraries (fixed Windows linkage) [[#148]](https://github.com/PJK/libcbor/pull/148) (by [intelligide@](https://github.com/intelligide)) +- BREAKING: Fix `cbor_tag_item` not increasing the reference count on the tagged item reference it returns [[Fixes #109](https://github.com/PJK/libcbor/issues/109)] (discovered bt [JohnGilmour](https://github.com/JohnGilmour)) + - If you have previously relied on the broken behavior, you can use `cbor_move` to emulate as long as the returned handle is an "rvalue" +- BREAKING: [`CBOR_DECODER_EBUFFER` removed from `cbor_decoder_status`](https://github.com/PJK/libcbor/pull/156) + - `cbor_stream_decode` will set `CBOR_DECODER_NEDATA` instead if the input buffer is empty +- [Fix `cbor_stream_decode`](https://github.com/PJK/libcbor/pull/156) to set `cbor_decoder_result.required` to the minimum number of input bytes necessary to receive the next callback (as long as at least one byte was passed) (discovered by [woefulwabbit](https://github.com/woefulwabbit)) +- Fixed several minor manpage issues [[#159]](https://github.com/PJK/libcbor/pull/159) (discovered by [kloczek@](https://github.com/kloczek)) + +0.7.0 (2020-04-25) +--------------------- +- Fix bad encoding of NaN half-floats [[Fixes #53]](https://github.com/PJK/libcbor/issues/53) (discovered by [BSipos-RKF](https://github.com/BSipos-RKF)) + - **Warning**: Previous versions encoded NaNs as `0xf9e700` instead of `0xf97e00`; if you rely on the broken behavior, this will be a breaking change +- Fix potentially bad encoding of negative half-float with exponent < -14 [[Fixes #112]](https://github.com/PJK/libcbor/issues/112) (discovered by [yami36](https://github.com/yami36)) +- BREAKING: Improved bool support [[Fixes #63]](https://github.com/PJK/libcbor/issues/63) + - Rename `cbor_ctrl_is_bool` to `cbor_get_bool` and fix the behavior + - Add `cbor_set_bool` +- Fix memory_allocation_test breaking the build without CBOR_CUSTOM_ALLOC [[Fixes #128]](https://github.com/PJK/libcbor/issues/128) (by [panlinux](https://github.com/panlinux)) +- [Fix a potential build issue where cJSON includes may be misconfigured](https://github.com/PJK/libcbor/pull/132) +- Breaking: [Add a limit on the size of the decoding context stack](https://github.com/PJK/libcbor/pull/138) (by [James-ZHANG](https://github.com/James-ZHANG)) + - If your usecase requires parsing very deeply nested structures, you might need to increase the default 2k limit via `CBOR_MAX_STACK_SIZE` +- Enable LTO/IPO based on [CheckIPOSupported](https://cmake.org/cmake/help/latest/module/CheckIPOSupported.html#module:CheckIPOSupported) [[#143]](https://github.com/PJK/libcbor/pull/143) (by [xanderlent](https://github.com/xanderlent)) + - If you rely on LTO being enabled and use CMake version older than 3.9, you will need to re-enable it manually or upgrade your CMake + +0.6.1 (2020-03-26) +--------------------- +- [Fix bad shared library version number](https://github.com/PJK/libcbor/pull/131) + - **Warning**: Shared library built from the 0.6.0 release is erroneously marked as version "0.6.0", which makes it incompatible with future releases *including the v0.6.X line* even though they may be compatible API/ABI-wise. Refer to the documentation for the new SO versioning scheme. + +0.6.0 (2020-03-15) +--------------------- +- Correctly set .so version [[Fixes #52]](https://github.com/PJK/libcbor/issues/52). + - **Warning**: All previous releases will be identified as 0.0 by the linker. +- Fix & prevent heap overflow error in example code [[#74]](https://github.com/PJK/libcbor/pull/74) [[#76]](https://github.com/PJK/libcbor/pull/76) (by @nevun) +- Correctly set OSX dynamic library version [[Fixes #75]](https://github.com/PJK/libcbor/issues/75) +- [Fix misplaced 0xFF bytes in maps possibly causing memory corruption](https://github.com/PJK/libcbor/pull/82) +- BREAKING: Fix handling & cleanup of failed memory allocation in constructor + and builder helper functions [[Fixes #84]](https://github.com/PJK/libcbor/issues/84) + - All cbor_new_* and cbor_build_* functions will now explicitly return NULL when memory allocation fails + - It is up to the client to handle such cases +- Globally enforced code style [[Fixes #83]](https://github.com/PJK/libcbor/issues/83) +- Fix issue possible memory corruption bug on repeated + cbor_(byte)string_add_chunk calls with intermittently failing realloc calls +- Fix possibly misaligned reads and writes when endian.h is uses or when + running on a big-endian machine [[Fixes #99](https://github.com/PJK/libcbor/issues/99), [#100](https://github.com/PJK/libcbor/issues/100)] +- [Improved CI setup with Travis-native arm64 support](https://github.com/PJK/libcbor/pull/116) +- [Docs migrated to Sphinx 2.4 and Python3](https://github.com/PJK/libcbor/pull/117) + +0.5.0 (2017-02-06) +--------------------- +- Remove cmocka from the subtree (always rely on system or user-provided version) +- Windows CI +- Only build tests if explicitly enabled (`-DWITH_TESTS=ON`) +- Fixed static header declarations (by cedric-d) +- Improved documentation (by Michael Richardson) +- Improved `examples/readfile.c` +- Reworked (re)allocation to handle huge inputs and overflows in size_t [[Fixes #16]](https://github.com/PJK/libcbor/issues/16) +- Improvements to C++ linkage (corrected `cbor_empty_callbacks`, fixed `restrict` pointers) (by Dennis Bijwaard) +- Fixed Linux installation directory depending on architecture [[Fixes #34]](https://github.com/PJK/libcbor/issues/34) (by jvymazal) +- Improved 32-bit support [[Fixes #35]](https://github.com/PJK/libcbor/issues/35) +- Fixed MSVC compatibility [[Fixes #31]](https://github.com/PJK/libcbor/issues/31) +- Fixed and improved half-float encoding [[Fixes #5](https://github.com/PJK/libcbor/issues/5), [#11](https://github.com/PJK/libcbor/issues/11)] + +0.4.0 (2015-12-25) +--------------------- +Breaks build & header compatibility due to: + +- Improved build configuration and feature check macros +- Endianess configuration fixes (by Erwin Kroon and David Grigsby) +- pkg-config compatibility (by Vincent Bernat) +- enable use of versioned SONAME (by Vincent Bernat) +- better fuzzer (wasn't random until now, ooops) + +0.3.1 (2015-05-21) +--------------------- +- documentation and comments improvements, mostly for the API reference + +0.3.0 (2015-05-21) +--------------------- + +- Fixes, polishing, niceties across the code base +- Updated examples +- `cbor_copy` +- `cbor_build_negint8`, 16, 32, 64, matching asserts +- `cbor_build_stringn` +- `cbor_build_tag` +- `cbor_build_float2`, ... + +0.2.1 (2015-05-17) +--------------------- +- C99 support + +0.2.0 (2015-05-17) +--------------------- + +- `cbor_ctrl_bool` -> `cbor_ctrl_is_bool` +- Added `cbor_array_allocated` & map equivalent +- Overhauled endianess conversion - ARM now works as expected +- 'sort.c' example added +- Significantly improved and doxyfied documentation + +0.1.0 (2015-05-06) +--------------------- + +The initial release, yay! diff --git a/contrib/libcbor/CMakeLists.txt b/contrib/libcbor/CMakeLists.txt new file mode 100644 index 000000000000..edba03720d2f --- /dev/null +++ b/contrib/libcbor/CMakeLists.txt @@ -0,0 +1,159 @@ +cmake_minimum_required(VERSION 2.8) +project(libcbor) +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/CMakeModules/") +include(CTest) + +SET(CBOR_VERSION_MAJOR "0") +SET(CBOR_VERSION_MINOR "8") +SET(CBOR_VERSION_PATCH "0") +SET(CBOR_VERSION ${CBOR_VERSION_MAJOR}.${CBOR_VERSION_MINOR}.${CBOR_VERSION_PATCH}) + +set(CMAKE_SKIP_INSTALL_ALL_DEPENDENCY true) +include(CheckIncludeFiles) + +include(TestBigEndian) +test_big_endian(BIG_ENDIAN) +if(BIG_ENDIAN) + add_definitions(-DIS_BIG_ENDIAN) +endif() + +option(CBOR_CUSTOM_ALLOC "Custom, dynamically defined allocator support" OFF) +option(CBOR_PRETTY_PRINTER "Include a pretty-printing routine" ON) +set(CBOR_BUFFER_GROWTH "2" CACHE STRING "Factor for buffer growth & shrinking") +set(CBOR_MAX_STACK_SIZE "2048" CACHE STRING "maximum size for decoding context stack") + +option(WITH_TESTS "[TEST] Build unit tests (requires CMocka)" OFF) +if(WITH_TESTS) + add_definitions(-DWITH_TESTS) +endif(WITH_TESTS) + +option(WITH_EXAMPLES "Build examples" ON) + +option(HUGE_FUZZ "[TEST] Fuzz through 8GB of data in the test. Do not use with memory instrumentation!" OFF) +if(HUGE_FUZZ) + add_definitions(-DHUGE_FUZZ) +endif(HUGE_FUZZ) + +option(SANE_MALLOC "[TEST] Assume that malloc will not allocate multi-GB blocks. Tests only, platform specific" OFF) +if(SANE_MALLOC) + add_definitions(-DSANE_MALLOC) +endif(SANE_MALLOC) + +option(PRINT_FUZZ "[TEST] Print the fuzzer input" OFF) +if(PRINT_FUZZ) + add_definitions(-DPRINT_FUZZ) +endif(PRINT_FUZZ) + +option(SANITIZE "Enable ASan & a few compatible sanitizers in Debug mode" ON) + +set(CPACK_GENERATOR "DEB" "TGZ" "RPM") +set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "amd64") +set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Pavel Kalvoda") +set(CPACK_DEBIAN_PACKAGE_DEPENDS "libc6") +set(CPACK_PACKAGE_VERSION_MAJOR ${CBOR_VERSION_MAJOR}) +set(CPACK_PACKAGE_VERSION_MINOR ${CBOR_VERSION_MINOR}) +set(CPACK_PACKAGE_VERSION_PATCH ${CBOR_VERSION_PATCH}) + +include(CPack) + +if(MINGW) + # https://github.com/PJK/libcbor/issues/13 + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99") +elseif(NOT MSVC) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99 -pedantic") +endif() + +if(MSVC) + # This just doesn't work right -- https://msdn.microsoft.com/en-us/library/5ft82fed.aspx + set(CBOR_RESTRICT_SPECIFIER "") +else() + set(CBOR_RESTRICT_SPECIFIER "restrict") + + set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -O0 -Wall -g -ggdb -DDEBUG=true") + set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -O3 -Wall -DNDEBUG") + + if(SANITIZE) + set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} \ + -fsanitize=undefined -fsanitize=address \ + -fsanitize=bounds -fsanitize=alignment") + endif() +endif() + +set(CMAKE_EXE_LINKER_FLAGS_DEBUG "-g") + + +include(CheckTypeSize) +check_type_size("size_t" SIZEOF_SIZE_T) +if(SIZEOF_SIZE_T LESS 8) + message(WARNING "Your size_t is less than 8 bytes. Long items with 64b length specifiers might not work as expected. Make sure to run the tests!") +else() + add_definitions(-DEIGHT_BYTE_SIZE_T) +endif() + +enable_testing() + +set(CTEST_MEMORYCHECK_COMMAND "/usr/bin/valgrind") +set(MEMORYCHECK_COMMAND_OPTIONS "--tool=memcheck --track-origins=yes --leak-check=full --error-exitcode=1") + +add_custom_target(coverage + COMMAND ctest + COMMAND lcov --capture --directory . --output-file coverage.info + COMMAND genhtml coverage.info --highlight --legend --output-directory coverage_html + COMMAND echo "Coverage report ready: file://${CMAKE_CURRENT_BINARY_DIR}/coverage_html/index.html") +include_directories(src) + + +option(COVERAGE "Enable code coverage instrumentation" OFF) +if (COVERAGE) + message("Configuring code coverage instrumentation") + if(NOT CMAKE_C_COMPILER MATCHES "gcc") + message(WARNING "Gcov instrumentation only works with GCC") + endif() + # https://gcc.gnu.org/onlinedocs/gcc/Debugging-Options.html + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -fprofile-arcs -ftest-coverage --coverage") + set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} -g -fprofile-arcs -ftest-coverage --coverage") +endif (COVERAGE) + + +# We want to generate configuration.h from the template and make it so that it is accessible using the same +# path during both library build and installed header use, without littering the source dir. +# Using cbor/configuration.h in the build dir works b/c headers will be installed to <prefix>/cbor +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/cbor/configuration.h.in ${PROJECT_BINARY_DIR}/cbor/configuration.h) +install(FILES ${PROJECT_BINARY_DIR}/cbor/configuration.h DESTINATION include/cbor) +# Make the header visible at compile time +include_directories(${PROJECT_BINARY_DIR}) + +# CMake >= 3.9.0 enables LTO for GCC and Clang with INTERPROCEDURAL_OPTIMIZATION +# Policy CMP0069 enables this behavior when we set the minimum CMake version < 3.9.0 +# Checking for LTO support before setting INTERPROCEDURAL_OPTIMIZATION is mandatory with CMP0069 set to NEW. +set(use_lto FALSE) +if(${CMAKE_VERSION} VERSION_GREATER "3.9.0" OR ${CMAKE_VERSION} VERSION_EQUAL "3.9.0") + cmake_policy(SET CMP0069 NEW) + # Require LTO support to build libcbor with newer CMake versions + include(CheckIPOSupported) + check_ipo_supported(RESULT use_lto) +endif(${CMAKE_VERSION} VERSION_GREATER "3.9.0" OR ${CMAKE_VERSION} VERSION_EQUAL "3.9.0") +if(use_lto) + message(STATUS "LTO is enabled") +else() + message(STATUS "LTO is not enabled") +endif(use_lto) + +subdirs(src) +if(use_lto) + set_property(DIRECTORY src PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE) +endif(use_lto) + +if (WITH_TESTS) + subdirs(test) + if(use_lto) + set_property(DIRECTORY test PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE) + endif(use_lto) +endif (WITH_TESTS) + +if (WITH_EXAMPLES) + subdirs(examples) + if(use_lto) + set_property(DIRECTORY examples PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE) + endif(use_lto) +endif (WITH_EXAMPLES) diff --git a/contrib/libcbor/CMakeModules/FindCJSON.cmake b/contrib/libcbor/CMakeModules/FindCJSON.cmake new file mode 100644 index 000000000000..e0629057def7 --- /dev/null +++ b/contrib/libcbor/CMakeModules/FindCJSON.cmake @@ -0,0 +1,9 @@ +include (LibFindMacros) + +find_path(CJSON_INCLUDE_DIR NAMES cjson/cJSON.h) +find_library(CJSON_LIBRARY NAMES cjson) + +set(CJSON_PROCESS_INCLUDES CJSON_INCLUDE_DIR) +set(CJSON_PROCESS_LIBS CJSON_LIBRARY) + +libfind_process(CJSON) diff --git a/contrib/libcbor/CMakeModules/FindCMocka.cmake b/contrib/libcbor/CMakeModules/FindCMocka.cmake new file mode 100644 index 000000000000..770b44afc426 --- /dev/null +++ b/contrib/libcbor/CMakeModules/FindCMocka.cmake @@ -0,0 +1,49 @@ +# - Try to find CMocka +# Once done this will define +# +# CMOCKA_ROOT_DIR - Set this variable to the root installation of CMocka +# +# Read-Only variables: +# CMOCKA_FOUND - system has CMocka +# CMOCKA_INCLUDE_DIR - the CMocka include directory +# CMOCKA_LIBRARIES - Link these to use CMocka +# CMOCKA_DEFINITIONS - Compiler switches required for using CMocka +# +#============================================================================= +# Copyright (c) 2011-2012 Andreas Schneider <asn@cryptomilk.org> +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# + +find_path(CMOCKA_INCLUDE_DIR + NAMES + cmocka.h + PATHS + ${CMOCKA_ROOT_DIR}/include +) + +find_library(CMOCKA_LIBRARY + NAMES + cmocka cmocka_shared + PATHS + ${CMOCKA_ROOT_DIR}/include +) + +if (CMOCKA_LIBRARY) + set(CMOCKA_LIBRARIES + ${CMOCKA_LIBRARIES} + ${CMOCKA_LIBRARY} + ) +endif (CMOCKA_LIBRARY) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(CMocka DEFAULT_MSG CMOCKA_LIBRARIES CMOCKA_INCLUDE_DIR) + +# show the CMOCKA_INCLUDE_DIR and CMOCKA_LIBRARIES variables only in the advanced view +mark_as_advanced(CMOCKA_INCLUDE_DIR CMOCKA_LIBRARIES) diff --git a/contrib/libcbor/CMakeModules/LibFindMacros.cmake b/contrib/libcbor/CMakeModules/LibFindMacros.cmake new file mode 100644 index 000000000000..baea8c2be928 --- /dev/null +++ b/contrib/libcbor/CMakeModules/LibFindMacros.cmake @@ -0,0 +1,120 @@ +# Fetched from https://github.com/JonathanSalwan/Triton/blob/master/CMakeModules/LibFindMacros.cmake +# +# Copyright: +# +# * Jonathan Salwan (Quarkslab) +# * Pierrick Brunet (Quarkslab) +# * Romain Thomas (Quarkslab) +# * Florent Saudel (Bordeaux University) +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Works the same as find_package, but forwards the "REQUIRED" and "QUIET" arguments +# used for the current package. For this to work, the first parameter must be the +# prefix of the current package, then the prefix of the new package etc, which are +# passed to find_package. +macro (libfind_package PREFIX) + set (LIBFIND_PACKAGE_ARGS ${ARGN}) + if (${PREFIX}_FIND_QUIETLY) + set (LIBFIND_PACKAGE_ARGS ${LIBFIND_PACKAGE_ARGS} QUIET) + endif (${PREFIX}_FIND_QUIETLY) + if (${PREFIX}_FIND_REQUIRED) + set (LIBFIND_PACKAGE_ARGS ${LIBFIND_PACKAGE_ARGS} REQUIRED) + endif (${PREFIX}_FIND_REQUIRED) + find_package(${LIBFIND_PACKAGE_ARGS}) +endmacro (libfind_package) + +# CMake developers made the UsePkgConfig system deprecated in the same release (2.6) +# where they added pkg_check_modules. Consequently I need to support both in my scripts +# to avoid those deprecated warnings. Here's a helper that does just that. +# Works identically to pkg_check_modules, except that no checks are needed prior to use. +macro (libfind_pkg_check_modules PREFIX PKGNAME) + if (${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 4) + include(UsePkgConfig) + pkgconfig(${PKGNAME} ${PREFIX}_INCLUDE_DIRS ${PREFIX}_LIBRARY_DIRS ${PREFIX}_LDFLAGS ${PREFIX}_CFLAGS) + else (${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 4) + find_package(PkgConfig) + if (PKG_CONFIG_FOUND) + pkg_check_modules(${PREFIX} ${PKGNAME}) + endif (PKG_CONFIG_FOUND) + endif (${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 4) +endmacro (libfind_pkg_check_modules) + +# Do the final processing once the paths have been detected. +# If include dirs are needed, ${PREFIX}_PROCESS_INCLUDES should be set to contain +# all the variables, each of which contain one include directory. +# Ditto for ${PREFIX}_PROCESS_LIBS and library files. +# Will set ${PREFIX}_FOUND, ${PREFIX}_INCLUDE_DIRS and ${PREFIX}_LIBRARIES. +# Also handles errors in case library detection was required, etc. +macro (libfind_process PREFIX) + # Skip processing if already processed during this run + if (NOT ${PREFIX}_FOUND) + # Start with the assumption that the library was found + set (${PREFIX}_FOUND TRUE) + + # Process all includes and set _FOUND to false if any are missing + foreach (i ${${PREFIX}_PROCESS_INCLUDES}) + if (${i}) + set (${PREFIX}_INCLUDE_DIRS ${${PREFIX}_INCLUDE_DIRS} ${${i}}) + mark_as_advanced(${i}) + else (${i}) + set (${PREFIX}_FOUND FALSE) + endif (${i}) + endforeach (i) + + # Process all libraries and set _FOUND to false if any are missing + foreach (i ${${PREFIX}_PROCESS_LIBS}) + if (${i}) + set (${PREFIX}_LIBRARIES ${${PREFIX}_LIBRARIES} ${${i}}) + mark_as_advanced(${i}) + else (${i}) + set (${PREFIX}_FOUND FALSE) + endif (${i}) + endforeach (i) + + # Print message and/or exit on fatal error + if (${PREFIX}_FOUND) + if (NOT ${PREFIX}_FIND_QUIETLY) + message (STATUS "Found ${PREFIX} include directory: ${${PREFIX}_INCLUDE_DIR}") + message (STATUS "Found ${PREFIX} library: ${${PREFIX}_LIBRARY}") + endif (NOT ${PREFIX}_FIND_QUIETLY) + else (${PREFIX}_FOUND) + if (${PREFIX}_FIND_REQUIRED) + foreach (i ${${PREFIX}_PROCESS_INCLUDES} ${${PREFIX}_PROCESS_LIBS}) + message("${i}=${${i}}") + endforeach (i) + message (FATAL_ERROR "Required library ${PREFIX} NOT FOUND.\nInstall the library (dev version) and try again. If the library is already installed, use ccmake to set the missing variables manually.") + endif (${PREFIX}_FIND_REQUIRED) + endif (${PREFIX}_FOUND) + endif (NOT ${PREFIX}_FOUND) +endmacro (libfind_process) + +macro(libfind_library PREFIX basename) + set(TMP "") + if(MSVC80) + set(TMP -vc80) + endif(MSVC80) + if(MSVC90) + set(TMP -vc90) + endif(MSVC90) + set(${PREFIX}_LIBNAMES ${basename}${TMP}) + if(${ARGC} GREATER 2) + set(${PREFIX}_LIBNAMES ${basename}${TMP}-${ARGV2}) + string(REGEX REPLACE "\\." "_" TMP ${${PREFIX}_LIBNAMES}) + set(${PREFIX}_LIBNAMES ${${PREFIX}_LIBNAMES} ${TMP}) + endif(${ARGC} GREATER 2) + find_library(${PREFIX}_LIBRARY + NAMES ${${PREFIX}_LIBNAMES} + PATHS ${${PREFIX}_PKGCONF_LIBRARY_DIRS} + ) +endmacro(libfind_library) diff --git a/contrib/libcbor/Doxyfile b/contrib/libcbor/Doxyfile new file mode 100644 index 000000000000..b197d2bcdedc --- /dev/null +++ b/contrib/libcbor/Doxyfile @@ -0,0 +1,2417 @@ +# Doxyfile 1.8.12 + +# This file describes the settings to be used by the documentation system +# doxygen (www.doxygen.org) for a project. +# +# All text after a double hash (##) is considered a comment and is placed in +# front of the TAG it is preceding. +# +# All text after a single hash (#) is considered a comment and will be ignored. +# The format is: +# TAG = value [value, ...] +# For lists, items can also be appended using: +# TAG += value [value, ...] +# Values that contain spaces should be placed between quotes (\" \"). + +#--------------------------------------------------------------------------- +# Project related configuration options +#--------------------------------------------------------------------------- + +# This tag specifies the encoding used for all characters in the config file +# that follow. The default is UTF-8 which is also the encoding used for all text +# before the first occurrence of this tag. Doxygen uses libiconv (or the iconv +# built into libc) for the transcoding. See http://www.gnu.org/software/libiconv +# for the list of possible encodings. +# The default value is: UTF-8. + +DOXYFILE_ENCODING = UTF-8 + +# The PROJECT_NAME tag is a single word (or a sequence of words surrounded by +# double-quotes, unless you are using Doxywizard) that should identify the +# project for which the documentation is generated. This name is used in the +# title of most generated pages and in a few other places. +# The default value is: My Project. + +PROJECT_NAME = "libcbor" + +# The PROJECT_NUMBER tag can be used to enter a project or revision number. This +# could be handy for archiving the generated documentation or if some version +# control system is used. + +PROJECT_NUMBER = 0.8.0 + +# Using the PROJECT_BRIEF tag one can provide an optional one line description +# for a project that appears at the top of each page and should give viewer a +# quick idea about the purpose of the project. Keep the description short. + +PROJECT_BRIEF = "libcbor is a C library for parsing and generating CBOR, the general-purpose schema-less binary data format." + +# With the PROJECT_LOGO tag one can specify a logo or an icon that is included +# in the documentation. The maximum height of the logo should not exceed 55 +# pixels and the maximum width should not exceed 200 pixels. Doxygen will copy +# the logo to the output directory. + +PROJECT_LOGO = + +# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) path +# into which the generated documentation will be written. If a relative path is +# entered, it will be relative to the location where doxygen was started. If +# left blank the current directory will be used. + +OUTPUT_DIRECTORY = doc/build/doxygen + +# If the CREATE_SUBDIRS tag is set to YES then doxygen will create 4096 sub- *** 16279 LINES SKIPPED ***