git: 5300b2093424 - stable/13 - libcbor: update to 0.10.2

From: Ed Maste <emaste_at_FreeBSD.org>
Date: Fri, 21 Jul 2023 15:38:36 UTC
The branch stable/13 has been updated by emaste:

URL: https://cgit.FreeBSD.org/src/commit/?id=5300b2093424826ea82a7d07574f584e0b9613ff

commit 5300b2093424826ea82a7d07574f584e0b9613ff
Author:     Ed Maste <emaste@FreeBSD.org>
AuthorDate: 2023-04-21 20:09:03 +0000
Commit:     Ed Maste <emaste@FreeBSD.org>
CommitDate: 2023-07-21 14:41:41 +0000

    libcbor: update to 0.10.2
    
    Sponsored by:   The FreeBSD Foundation
    
    (cherry picked from commit 5d3e7166f6a0187fa3f8831b16a06bd9955c21ff)
---
 contrib/libcbor/.circleci/config.yml               | 224 ++++++
 .../libcbor/.github/ISSUE_TEMPLATE/bug_report.md   |  20 +
 contrib/libcbor/.github/PULL_REQUEST_TEMPLATE      |  15 +
 contrib/libcbor/.github/workflows/fuzz-pr.yml      |  25 +
 contrib/libcbor/.github/workflows/fuzz.yml         |   6 +-
 contrib/libcbor/.gitignore                         |   8 +
 contrib/libcbor/.travis.yml                        |  66 --
 contrib/libcbor/Bazel.md                           | 100 +++
 contrib/libcbor/CHANGELOG.md                       |  47 ++
 contrib/libcbor/CMakeLists.txt                     |  54 +-
 contrib/libcbor/CMakeModules/FindCMocka.cmake      |   8 +
 contrib/libcbor/CMakeModules/JoinPaths.cmake       |  23 +
 contrib/libcbor/CONTRIBUTING.md                    |  35 +
 contrib/libcbor/Doxyfile                           | 778 ++++++++++++++-------
 contrib/libcbor/README.md                          |  54 +-
 contrib/libcbor/appveyor.yml                       |  19 +-
 contrib/libcbor/clang-format.sh                    |   9 +-
 contrib/libcbor/codecov.yml                        |   9 +-
 contrib/libcbor/doc/source/api.rst                 |   4 +-
 contrib/libcbor/doc/source/api/encoding.rst        |   4 +
 .../doc/source/api/item_reference_counting.rst     |  19 +-
 .../decoding.rst => api/streaming_decoding.rst}    |  14 +-
 .../libcbor/doc/source/api/streaming_encoding.rst  |  65 ++
 contrib/libcbor/doc/source/api/type_2.rst          |   5 -
 contrib/libcbor/doc/source/api/type_3.rst          |   6 +-
 contrib/libcbor/doc/source/api/type_4.rst          |   9 +-
 contrib/libcbor/doc/source/api/type_5.rst          |  26 +-
 contrib/libcbor/doc/source/api/type_7.rst          |   9 +-
 contrib/libcbor/doc/source/conf.py                 |   4 +-
 contrib/libcbor/doc/source/getting_started.rst     |   7 +-
 contrib/libcbor/doc/source/index.rst               |   1 -
 contrib/libcbor/doc/source/requirements.txt        |  60 +-
 contrib/libcbor/doc/source/rfc_conformance.rst     |   4 +-
 contrib/libcbor/doc/source/streaming.rst           |  13 -
 contrib/libcbor/doc/source/streaming/encoding.rst  |   4 -
 contrib/libcbor/doc/source/using.rst               |  11 +-
 contrib/libcbor/examples/CMakeLists.txt            |   3 +
 contrib/libcbor/examples/bazel/README.md           |  33 +
 contrib/libcbor/examples/bazel/WORKSPACE           |  19 +
 contrib/libcbor/examples/bazel/src/BUILD           |  46 ++
 contrib/libcbor/examples/bazel/src/hello.cc        |   7 +
 contrib/libcbor/examples/bazel/src/hello.h         |   8 +
 contrib/libcbor/examples/bazel/src/hello_test.cc   |  10 +
 contrib/libcbor/examples/bazel/src/main.cc         |  10 +
 contrib/libcbor/examples/bazel/third_party/BUILD   |   1 +
 .../examples/bazel/third_party/libcbor.BUILD       |  21 +
 .../examples/bazel/third_party/libcbor/BUILD       |  11 +
 .../bazel/third_party/libcbor/cbor/cbor_export.h   |  42 ++
 .../bazel/third_party/libcbor/cbor/configuration.h |  15 +
 contrib/libcbor/examples/cjson2cbor.c              |   8 +-
 contrib/libcbor/examples/create_items.c            |  25 +-
 contrib/libcbor/examples/hello.c                   |   3 +-
 contrib/libcbor/examples/readfile.c                |   3 +-
 contrib/libcbor/examples/sort.c                    |  15 +-
 contrib/libcbor/examples/streaming_array.c         |  47 ++
 contrib/libcbor/examples/streaming_parser.c        |  10 +-
 contrib/libcbor/misc/update_version.py             |  29 +-
 contrib/libcbor/oss-fuzz/build.sh                  |   2 +-
 contrib/libcbor/oss-fuzz/cbor_load_fuzzer.cc       |  54 +-
 contrib/libcbor/release.sh                         |   8 +-
 contrib/libcbor/src/CMakeLists.txt                 |  18 +-
 contrib/libcbor/src/cbor.c                         | 144 ++--
 contrib/libcbor/src/cbor.h                         |  26 +-
 contrib/libcbor/src/cbor/arrays.c                  |  22 +-
 contrib/libcbor/src/cbor/arrays.h                  |  71 +-
 contrib/libcbor/src/cbor/bytestrings.c             |  40 +-
 contrib/libcbor/src/cbor/bytestrings.h             |  54 +-
 contrib/libcbor/src/cbor/callbacks.c               | 153 ++--
 contrib/libcbor/src/cbor/callbacks.h               |  14 +-
 contrib/libcbor/src/cbor/common.c                  |  29 +-
 contrib/libcbor/src/cbor/common.h                  | 152 ++--
 contrib/libcbor/src/cbor/configuration.h.in        |   1 -
 contrib/libcbor/src/cbor/data.h                    |  11 +-
 contrib/libcbor/src/cbor/encoding.c                |  20 +-
 contrib/libcbor/src/cbor/encoding.h                | 103 ++-
 contrib/libcbor/src/cbor/floats_ctrls.c            |  64 +-
 contrib/libcbor/src/cbor/floats_ctrls.h            | 114 +--
 .../libcbor/src/cbor/internal/builder_callbacks.c  | 230 +++---
 .../libcbor/src/cbor/internal/builder_callbacks.h  |  12 +-
 contrib/libcbor/src/cbor/internal/encoders.c       |  28 +-
 contrib/libcbor/src/cbor/internal/encoders.h       |   5 +
 contrib/libcbor/src/cbor/internal/loaders.c        |   2 +-
 contrib/libcbor/src/cbor/internal/loaders.h        |   9 +-
 contrib/libcbor/src/cbor/internal/memory_utils.c   |  17 +-
 contrib/libcbor/src/cbor/internal/memory_utils.h   |  13 +-
 contrib/libcbor/src/cbor/internal/stack.c          |   6 +-
 contrib/libcbor/src/cbor/internal/stack.h          |  14 +-
 contrib/libcbor/src/cbor/internal/unicode.c        |   9 +-
 contrib/libcbor/src/cbor/internal/unicode.h        |   7 +-
 contrib/libcbor/src/cbor/ints.c                    |  59 +-
 contrib/libcbor/src/cbor/ints.h                    |  61 +-
 contrib/libcbor/src/cbor/maps.c                    |  21 +-
 contrib/libcbor/src/cbor/maps.h                    |  65 +-
 contrib/libcbor/src/cbor/serialization.c           | 276 +++++---
 contrib/libcbor/src/cbor/serialization.h           | 135 ++--
 contrib/libcbor/src/cbor/streaming.c               | 181 ++---
 contrib/libcbor/src/cbor/streaming.h               |  10 +-
 contrib/libcbor/src/cbor/strings.c                 |  39 +-
 contrib/libcbor/src/cbor/strings.h                 |  87 ++-
 contrib/libcbor/src/cbor/tags.c                    |  11 +-
 contrib/libcbor/src/cbor/tags.h                    |  35 +-
 contrib/libcbor/src/libcbor.pc.in                  |   4 +-
 contrib/libcbor/test/CMakeLists.txt                |  14 +-
 ...ype_4_encoders_test.c => array_encoders_test.c} |  31 +-
 contrib/libcbor/test/array_test.c                  | 222 ++++++
 contrib/libcbor/test/assertions.c                  |  32 +-
 contrib/libcbor/test/assertions.h                  |  20 +-
 contrib/libcbor/test/bad_inputs_test.c             |  43 +-
 ..._encoders_test.c => bytestring_encoders_test.c} |  20 +-
 .../test/{type_2_test.c => bytestring_test.c}      | 122 +++-
 contrib/libcbor/test/callbacks_test.c              | 374 +++++++++-
 contrib/libcbor/test/cbor_serialize_test.c         | 490 +++++++++++--
 contrib/libcbor/test/cbor_stream_decode_test.c     | 274 ++++++--
 contrib/libcbor/test/copy_test.c                   | 346 +++++++--
 contrib/libcbor/test/float_ctrl_encoders_test.c    | 213 ++++++
 .../test/{type_7_test.c => float_ctrl_test.c}      |  80 ++-
 contrib/libcbor/test/fuzz_test.c                   |  15 +-
 ...{type_5_encoders_test.c => map_encoders_test.c} |  21 +-
 contrib/libcbor/test/{type_5_test.c => map_test.c} | 120 +++-
 contrib/libcbor/test/memory_allocation_test.c      | 277 --------
 contrib/libcbor/test/memory_utils_test.c           |  59 ++
 ...pe_1_encoders_test.c => negint_encoders_test.c} |  49 +-
 .../libcbor/test/{type_1_test.c => negint_test.c}  |  40 +-
 contrib/libcbor/test/pretty_printer_test.c         |   9 +-
 contrib/libcbor/test/stack_over_limit_test.c       |  15 +-
 contrib/libcbor/test/stream_expectations.c         | 107 +--
 contrib/libcbor/test/stream_expectations.h         |  71 +-
 ...pe_3_encoders_test.c => string_encoders_test.c} |  21 +-
 .../libcbor/test/{type_3_test.c => string_test.c}  | 112 ++-
 ...{type_6_encoders_test.c => tag_encoders_test.c} |  15 +-
 contrib/libcbor/test/{type_6_test.c => tag_test.c} |  59 +-
 contrib/libcbor/test/test_allocator.c              |  89 +++
 contrib/libcbor/test/test_allocator.h              |  35 +
 contrib/libcbor/test/type_4_test.c                 | 127 ----
 contrib/libcbor/test/type_7_encoders_test.c        | 109 ---
 ...type_0_encoders_test.c => uint_encoders_test.c} |  46 +-
 .../libcbor/test/{type_0_test.c => uint_test.c}    |  58 +-
 contrib/libcbor/test/unicode_test.c                |  23 +-
 lib/libcbor/Makefile                               |   3 +-
 139 files changed, 5668 insertions(+), 2660 deletions(-)

diff --git a/contrib/libcbor/.circleci/config.yml b/contrib/libcbor/.circleci/config.yml
new file mode 100644
index 000000000000..69371b67d624
--- /dev/null
+++ b/contrib/libcbor/.circleci/config.yml
@@ -0,0 +1,224 @@
+version: 2.1
+
+commands:
+  linux-setup:
+    steps:
+    - run: sudo apt-get update
+    - run: sudo apt-get install -y cmake ${TOOLCHAIN_PACKAGES}
+    - run: sudo apt install libcmocka-dev
+  build:
+    steps:
+    - run: >
+        cmake -DWITH_TESTS=ON \
+          -DCMAKE_BUILD_TYPE=Debug \
+          -DSANITIZE=OFF \
+          -DCOVERAGE="${CMAKE_COVERAGE:='OFF'}" \
+          .
+    - run: make -j 16 VERBOSE=1
+  build-release:
+    steps:
+    - run: >
+        cmake -DWITH_TESTS=ON \
+          -DCMAKE_BUILD_TYPE=Release \
+          .
+    - run: make -j 16 VERBOSE=1
+  test:
+    steps:
+    - run: ctest -VV
+
+orbs:
+  codecov: codecov/codecov@3.2.2
+
+jobs:
+  static-test:
+    machine:
+      image: ubuntu-2204:2022.10.2
+    environment:
+      TOOLCHAIN_PACKAGES: g++
+    steps:
+      - checkout
+      - linux-setup
+      - run: sudo apt-get install -y clang-format doxygen cppcheck
+      - run: cppcheck --inline-suppr --error-exitcode=1 .
+      - run: bash clang-format.sh --verbose
+      - run: >
+          if ! $(git diff-index --quiet HEAD); then
+            echo "Code formatting doesn't conform to clang-format"
+            echo "Please run clang-format.sh, commit the diff, and push to re-run CI"
+            echo "Excerpt of the diff follows"
+            git diff | head -n 20
+          fi
+      - run: >
+          if doxygen Doxyfile | grep 'warning: '; then
+            echo "Doxygen warning (see above) -- misformatted docs?"
+            exit 1
+          fi
+      - run: >
+          cd doc &&
+          pip3 install -r source/requirements.txt &&
+          make html
+
+  build-and-test:
+    machine:
+      image: ubuntu-2204:2022.10.2
+    environment:
+      TOOLCHAIN_PACKAGES: g++
+      CMAKE_COVERAGE: ON
+    steps:
+      - checkout
+      - linux-setup
+      - run: sudo apt-get install -y valgrind
+      - build
+      - test
+      - run: ctest -T Coverage
+      - codecov/upload
+      - run: ctest --output-on-failure -T memcheck | tee memcheck.out
+      - run: >
+          if grep -q 'Memory Leak\|IPW\|Uninitialized Memory Conditional\|Uninitialized Memory Read' memcheck.out; then
+            cat Testing/Temporary/MemoryChecker*
+            exit 1
+          fi;
+
+  build-and-test-clang:
+    machine:
+      image: ubuntu-2204:2022.10.2
+    environment:
+      TOOLCHAIN_PACKAGES: clang
+      CC: clang
+      CXX: clang++
+    steps:
+      - checkout
+      - linux-setup
+      - build
+      - test
+
+  build-and-test-32b:
+    machine:
+      image: ubuntu-2204:2022.10.2
+    steps:
+      - checkout
+      - run: sudo apt-get update
+      - run: sudo apt-get install -y cmake gcc-multilib g++-multilib libc6-dev-i386
+      # Make cmocka from source w/ 32b setup
+      - run: git clone https://git.cryptomilk.org/projects/cmocka.git ~/cmocka
+      - run: >
+          cd $(mktemp -d /tmp/build.XXXX) &&
+          cmake ~/cmocka -DCMAKE_TOOLCHAIN_FILE=~/cmocka/cmake/Toolchain-cross-m32.cmake &&
+          make &&
+          sudo make install
+      # Piggyback on the cmocka 32b toolchain
+      - run: >
+          cmake -DWITH_TESTS=ON \
+            -DCMAKE_BUILD_TYPE=Debug \
+            -DCMAKE_TOOLCHAIN_FILE=~/cmocka/cmake/Toolchain-cross-m32.cmake \
+            .
+      - run: make -j 16 VERBOSE=1
+      - test
+
+  build-and-test-release-clang:
+    machine:
+      image: ubuntu-2204:2022.10.2
+    environment:
+      TOOLCHAIN_PACKAGES: clang
+      CC: clang
+      CXX: clang++
+    steps:
+      - checkout
+      - linux-setup
+      - build-release
+      - test
+
+  llvm-coverage:
+    machine:
+      image: ubuntu-2204:2022.10.2
+    environment:
+      TOOLCHAIN_PACKAGES: clang
+      CC: clang
+      CXX: clang++
+      CMAKE_COVERAGE: ON
+    steps:
+      - checkout
+      - linux-setup
+      - build
+      - run: make llvm-coverage
+
+
+  build-and-test-arm:
+    machine:
+      image: ubuntu-2204:2022.10.2
+    environment:
+      TOOLCHAIN_PACKAGES: g++
+    resource_class: arm.medium
+    steps:
+      - checkout
+      - linux-setup
+      - build
+      - test
+
+  build-bazel:
+    machine:
+      image: ubuntu-2204:2022.10.2
+    environment:
+      TOOLCHAIN_PACKAGES: g++
+    steps:
+      - checkout
+      - linux-setup
+      - run: sudo apt install apt-transport-https curl gnupg
+      - run: curl -fsSL https://bazel.build/bazel-release.pub.gpg | gpg --dearmor > bazel.gpg
+      - run: sudo mv bazel.gpg /etc/apt/trusted.gpg.d/
+      - run: echo "deb [arch=amd64] https://storage.googleapis.com/bazel-apt stable jdk1.8" | sudo tee /etc/apt/sources.list.d/bazel.list
+      - run: sudo apt update
+      - run: sudo apt install bazel
+      - run: bazel --version
+      - run: >
+          pushd examples/bazel &&
+          bazel run -s src:hello
+
+  build-and-test-osx:
+    macos:
+      xcode: 12.5.1
+    steps:
+      - checkout
+      - run: bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
+      - run: brew install cmocka cmake
+      - build
+      - test
+
+  
+  build-and-test-win:
+    resource_class: 'windows.medium'
+    machine:
+      image: 'windows-server-2022-gui:current'
+      shell: 'bash.exe'
+    steps:
+      - checkout
+      - run: choco install cmake -y
+      - run: git clone https://git.cryptomilk.org/projects/cmocka.git
+      - run: cd cmocka && git checkout tags/cmocka-1.1.5 
+      - run: /c/Program\ Files/Cmake/bin/cmake -S cmocka -B cmocka_build
+      - run: /c/Program\ Files/Cmake/bin/cmake --build cmocka_build
+      - run: /c/Program\ Files/Cmake/bin/cmake -S . -B libcbor_build -DWITH_TESTS=ON -DCMOCKA_INCLUDE_DIR=cmocka/include -DCMOCKA_LIBRARIES=$(pwd)/cmocka_build/src/Debug/cmocka.lib
+      - run: /c/Program\ Files/Cmake/bin/cmake --build libcbor_build
+      - run: >
+          export PATH="$(pwd)/cmocka_build/src/Debug/:$PATH" &&
+          /c/Program\ Files/Cmake/bin/ctest.exe --test-dir libcbor_build --output-on-failure
+
+workflows:
+  build-and-test:
+    jobs:
+      - static-test
+      - build-and-test
+      - build-and-test-clang
+      - build-and-test-32b
+      - build-and-test-release-clang
+      - build-and-test-arm
+      - build-and-test-win
+      - build-bazel
+      - llvm-coverage
+      # OSX builds are expensive, run only on master
+      - build-and-test-osx:
+          requires:
+            - build-and-test
+          filters:
+            branches:
+              only: [master]
diff --git a/contrib/libcbor/.github/ISSUE_TEMPLATE/bug_report.md b/contrib/libcbor/.github/ISSUE_TEMPLATE/bug_report.md
new file mode 100644
index 000000000000..75997d8424cc
--- /dev/null
+++ b/contrib/libcbor/.github/ISSUE_TEMPLATE/bug_report.md
@@ -0,0 +1,20 @@
+---
+name: Bug report
+about: Create a report to help us improve
+title: ''
+labels: bug
+assignees: PJK
+
+---
+
+**Describe the bug**
+A clear and concise description of what the bug is.
+
+**To Reproduce**
+Steps to reproduce the behavior. If possible, please attach a runnable code snippet.
+
+**Expected behavior**
+A clear and concise description of what you expected to happen.
+
+**Environment**
+libcbor version and build configuration flags (or source package version if using a package manager).
diff --git a/contrib/libcbor/.github/PULL_REQUEST_TEMPLATE b/contrib/libcbor/.github/PULL_REQUEST_TEMPLATE
new file mode 100644
index 000000000000..1174d56f9c7a
--- /dev/null
+++ b/contrib/libcbor/.github/PULL_REQUEST_TEMPLATE
@@ -0,0 +1,15 @@
+## Description
+
+What changes and why
+
+## Checklist
+
+- [ ] I have read followed [CONTRIBUTING.md](https://github.com/PJK/libcbor/blob/master/CONTRIBUTING.md)
+	- [ ] I have added tests
+	- [ ] I have updated the documentation
+	- [ ] I have updated the CHANGELOG
+- [ ] Are there any breaking changes?
+	- [ ] If yes: I have marked them in the CHANGELOG ([example](https://github.com/PJK/libcbor/blob/87e2d48a127968d39f158cbfc2b79d6285bd039d/CHANGELOG.md?plain=1#L16))
+- [ ] Does this PR introduce any platform specific code?
+- [ ] Security: Does this PR potentially affect security?
+- [ ] Performance: Does this PR potentially affect performance?
diff --git a/contrib/libcbor/.github/workflows/fuzz-pr.yml b/contrib/libcbor/.github/workflows/fuzz-pr.yml
new file mode 100644
index 000000000000..0e3c4fde4e02
--- /dev/null
+++ b/contrib/libcbor/.github/workflows/fuzz-pr.yml
@@ -0,0 +1,25 @@
+# A quick CIFuzz sanity check. Fuzzing time is kept low provide fast feedback
+# on PRs; fuzz.yml schedules a daily long-running fuzzing job.
+name: CIFuzz PR check
+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: Smoke Test Fuzzers
+      uses: google/oss-fuzz/infra/cifuzz/actions/run_fuzzers@master
+      with:
+        oss-fuzz-project-name: 'libcbor'
+        fuzz-seconds: 10
+        dry-run: false
+    - name: Upload Crash
+      uses: actions/upload-artifact@v1
+      if: failure()
+      with:
+        name: artifacts
+        path: ./out/artifacts
diff --git a/contrib/libcbor/.github/workflows/fuzz.yml b/contrib/libcbor/.github/workflows/fuzz.yml
index c5275121868f..8603cc2f338e 100644
--- a/contrib/libcbor/.github/workflows/fuzz.yml
+++ b/contrib/libcbor/.github/workflows/fuzz.yml
@@ -1,5 +1,7 @@
 name: CIFuzz
-on: [pull_request]
+on:
+  schedule:
+    - cron:  '0 4 * * *'
 jobs:
   Fuzzing:
     runs-on: ubuntu-latest
@@ -13,7 +15,7 @@ jobs:
       uses: google/oss-fuzz/infra/cifuzz/actions/run_fuzzers@master
       with:
         oss-fuzz-project-name: 'libcbor'
-        fuzz-seconds: 600
+        fuzz-seconds: 14400 # 4 hours
         dry-run: false
     - name: Upload Crash
       uses: actions/upload-artifact@v1
diff --git a/contrib/libcbor/.gitignore b/contrib/libcbor/.gitignore
index b6fe00f938ad..61f88a874965 100644
--- a/contrib/libcbor/.gitignore
+++ b/contrib/libcbor/.gitignore
@@ -6,3 +6,11 @@ doxygen_docs
 */*.out
 cmake-build-debug
 venv
+**.DS_Store
+.vscode
+# No top-level requirements, see doc/source
+requirements.txt
+examples/bazel/bazel-bazel
+examples/bazel/bazel-bin
+examples/bazel/bazel-out
+examples/bazel/bazel-testlogs
diff --git a/contrib/libcbor/.travis.yml b/contrib/libcbor/.travis.yml
deleted file mode 100644
index 288de2903399..000000000000
--- a/contrib/libcbor/.travis.yml
+++ /dev/null
@@ -1,66 +0,0 @@
-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/Bazel.md b/contrib/libcbor/Bazel.md
new file mode 100644
index 000000000000..9fa2081f58fc
--- /dev/null
+++ b/contrib/libcbor/Bazel.md
@@ -0,0 +1,100 @@
+# Use as a Bazel Dependency
+
+To use libcbor in your
+[Baze](https://bazel.build/)
+project, first add the following section to your project's `WORKSPACE` file.
+Note the location of the `third_party/libcbor.BUILD` file - you may use a
+different location if you wish, but you the file must be make available to
+`WORKSPACE`.
+
+## WORKSPACE
+
+Note, this imports version `0.8.0` - you may need to update the version and
+the sha256 hash.
+
+```python
+# libcbor
+http_archive(
+    name = "libcbor",
+    build_file = "//third_party:libcbor.BUILD",
+    sha256 = "dd04ea1a7df484217058d389e027e7a0143a4f245aa18a9f89a5dd3e1a4fcc9a",
+    strip_prefix = "libcbor-0.8.0",
+    urls = ["https://github.com/PJK/libcbor/archive/refs/tags/v0.8.0.zip"],
+)
+```
+
+## third_party/libcbor.BUILD
+
+Bazel will unzip the libcbor zip file, then copy this file in as `BUILD`.
+Bazel will then use this file to compile libcbor.
+[Cmake](https://cmake.org/)
+is used in two passes: to create the Makefiles, and then to invoke Make to build
+the `libcbor.a` static library. `libcbor.a` and the `.h` files are then made
+available for other packages to use.
+
+```python
+genrule(
+  name = "cbor_cmake",
+  srcs = glob(["**"]),
+  outs = ["libcbor.a", "cbor.h", "cbor/arrays.h", "cbor/bytestrings.h",
+          "cbor/callbacks.h", "cbor/cbor_export.h", "cbor/common.h", "cbor/configuration.h", "cbor/data.h",
+          "cbor/encoding.h", "cbor/floats_ctrls.h", "cbor/ints.h", "cbor/maps.h",
+          "cbor/serialization.h", "cbor/streaming.h", "cbor/strings.h", "cbor/tags.h"],
+  cmd = " && ".join([
+    # Remember where output should go.
+    "INITIAL_WD=`pwd`",
+    # Build libcbor library.
+    "cd `dirname $(location CMakeLists.txt)`",
+    "cmake -DCMAKE_BUILD_TYPE=Release .",
+    "cmake --build .",
+    # Export the .a and .h files for cbor rule, below.
+    "cp src/libcbor.a src/cbor.h $$INITIAL_WD/$(RULEDIR)",
+    "cp src/cbor/*h cbor/configuration.h $$INITIAL_WD/$(RULEDIR)/cbor"]),
+  visibility = ["//visibility:private"],
+)
+
+cc_import(
+  name = "cbor",
+  hdrs = ["cbor.h", "cbor/arrays.h", "cbor/bytestrings.h",
+          "cbor/callbacks.h", "cbor/cbor_export.h", "cbor/common.h", "cbor/configuration.h", "cbor/data.h",
+          "cbor/encoding.h", "cbor/floats_ctrls.h", "cbor/ints.h", "cbor/maps.h",
+          "cbor/serialization.h", "cbor/streaming.h", "cbor/strings.h", "cbor/tags.h"],
+  static_library = "libcbor.a",
+  visibility = ["//visibility:public"],
+)
+```
+
+## third_party/BUILD
+
+The `libcbor.BUILD` file must be make available to the top-level `WORKSPACE`
+file:
+
+```python
+exports_files(["libcbor.BUILD"]))
+```
+
+## Your BUILD File
+
+Add libcbor dependency to your package's `BUILD` file like so:
+
+```python
+cc_library(
+    name = "...",
+    srcs = [ ... ],
+    hdrs = [ ... ],
+    deps = [
+        ...
+        "@libcbor//:cbor",
+    ],
+)
+```
+
+## Your C File
+
+Now you may simply include `cbor.h`:
+
+```c
+#include "cbor.h"
+
+static const uint8_t version = cbor_major_version;
+```
diff --git a/contrib/libcbor/CHANGELOG.md b/contrib/libcbor/CHANGELOG.md
index 0f13a45d6b24..f2475f308c7a 100644
--- a/contrib/libcbor/CHANGELOG.md
+++ b/contrib/libcbor/CHANGELOG.md
@@ -1,6 +1,53 @@
+Template:
+- [Fix issue X in feature Y](https://github.com/PJK/libcbor/pull/XXX) (by [YYY](https://github.com/YYY))
+
 Next
 ---------------------
 
+0.10.2 (2023-01-31)
+---------------------
+- [Fixed minor test bug causing failures for x86 Linux](https://github.com/PJK/libcbor/pull/266) (discovered by [trofi](https://github.com/PJK/libcbor/issues/263))
+  - Actual libcbor functionality not affected, bug was in the test suite
+- [Made tests platform-independent](https://github.com/PJK/libcbor/pull/272)
+
+0.10.1 (2022-12-30)
+---------------------
+- [Fix a regression in `cbor_serialize_alloc` that caused serialization of zero-length strings and bytestrings or byte/strings with zero-length chunks to fail](https://github.com/PJK/libcbor/pull/260) (discovered by [martelletto](https://github.com/martelletto))
+
+0.10.0 (2022-12-29)
+---------------------
+- Make the buffer_size optional in `cbor_serialize_alloc` [[#205]](https://github.com/PJK/libcbor/pull/205) (by [hughsie](https://github.com/hughsie))
+- BREAKING: Improved half-float encoding for denormalized numbers. [[#208]](https://github.com/PJK/libcbor/pull/208) (by [ranvis](https://github.com/ranvis))
+  - Denormalized half-floats will now preserve data in the mantissa
+  - Note: Half-float NaNs still lose data (https://github.com/PJK/libcbor/issues/215)
+- BUILD BREAKING: Minimum CMake version is 3.0 [[#201]](https://github.com/PJK/libcbor/pull/201) (by [thewtex@](https://github.com/thewtex))
+  - See https://repology.org/project/cmake/versions for support; the vast majority of users should not be affected.
+- Fix a potential memory leak when the allocator fails during array or map decoding [[#224]](https://github.com/PJK/libcbor/pull/224) (by [James-ZHANG](https://github.com/James-ZHANG))
+- [Fix a memory leak when the allocator fails when adding chunks to indefinite bytestrings.](https://github.com/PJK/libcbor/pull/242) ([discovered](https://github.com/PJK/libcbor/pull/228) by [James-ZHANG](https://github.com/James-ZHANG))
+- [Fix a memory leak when the allocator fails when adding chunks to indefinite strings](https://github.com/PJK/libcbor/pull/246)
+- Potentially BUILD BREAKING: [Add nodiscard attributes to most functions](https://github.com/PJK/libcbor/pull/248)
+  - **Warning**: This may cause new build warnings and (in rare cases, depending on your configuration) errors
+- BREAKING: [Fix `cbor_copy` leaking memory and creating invalid items when the allocator fails](https://github.com/PJK/libcbor/pull/249).
+  - Previously, the failures were not handled in the interface. Now, `cbor_copy` may return `NULL` upon failure; clients should check the return value
+- [Fix `cbor_build_tag` illegal memory behavior when the allocator fails](https://github.com/PJK/libcbor/pull/249)
+- [Add a new `cbor_serialized_size` API](https://github.com/PJK/libcbor/pull/250)
+- [Reworked `cbor_serialize_alloc` to allocate the exact amount of memory necessary upfront](https://github.com/PJK/libcbor/pull/251)
+  - This should significantly speed up `cbor_serialize_alloc` for large items by avoiding multiple reallocation iterations
+  - Clients should not use the return value of `cbor_serialize_alloc`. It may be removed in the future.
+- BUILD BREAKING: [Deprecate CBOR_CUSTOM_ALLOC](https://github.com/PJK/libcbor/pull/237)
+  - `cbor_set_allocs` will always be enabled from now on
+  - Note: The flag will be kept as a no-op triggering a warning when used for one version and then removed completely
+
+0.9.0 (2021-11-14)
+---------------------
+- Improved pkg-config paths handling [[#164]](https://github.com/PJK/libcbor/pull/164) (by [jtojnar@](https://github.com/jtojnar))
+- Use explicit math.h linkage [[#170]](https://github.com/PJK/libcbor/pull/170)
+- BREAKING: Fixed handling of items that exceed the host size_t range [[#186]](https://github.com/PJK/libcbor/pull/186hg)  
+    - Callbacks for bytestrings, strings, arrays, and maps use uint64_t instead of size_t to allow handling of large items that exceed size_t even if size_t < uint64_t
+    - cbor_decode explicitly checks size to avoid overflows (previously broken, potentially resulting in erroneous decoding on affected systems)
+    - The change should be a noop for 64b systems 
+- Added a [Bazel](https://bazel.build/) build example [[#196]](https://github.com/PJK/libcbor/pull/196) (by [andyjgf@](https://github.com/andyjgf))
+
 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))
diff --git a/contrib/libcbor/CMakeLists.txt b/contrib/libcbor/CMakeLists.txt
index edba03720d2f..5c0a7846cfa3 100644
--- a/contrib/libcbor/CMakeLists.txt
+++ b/contrib/libcbor/CMakeLists.txt
@@ -1,11 +1,11 @@
-cmake_minimum_required(VERSION 2.8)
+cmake_minimum_required(VERSION 3.0)
 project(libcbor)
-set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/CMakeModules/")
+set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules/")
 include(CTest)
 
 SET(CBOR_VERSION_MAJOR "0")
-SET(CBOR_VERSION_MINOR "8")
-SET(CBOR_VERSION_PATCH "0")
+SET(CBOR_VERSION_MINOR "10")
+SET(CBOR_VERSION_PATCH "2")
 SET(CBOR_VERSION ${CBOR_VERSION_MAJOR}.${CBOR_VERSION_MINOR}.${CBOR_VERSION_PATCH})
 
 set(CMAKE_SKIP_INSTALL_ALL_DEPENDENCY true)
@@ -18,6 +18,13 @@ if(BIG_ENDIAN)
 endif()
 
 option(CBOR_CUSTOM_ALLOC "Custom, dynamically defined allocator support" OFF)
+if(CBOR_CUSTOM_ALLOC)
+    message(WARNING 
+        "CBOR_CUSTOM_ALLOC has been deprecated. Custom allocators are now enabled by default."
+        "The flag is a no-op and will be removed in the next version. "
+        "Please remove CBOR_CUSTOM_ALLOC from your build configuation.")
+endif(CBOR_CUSTOM_ALLOC)
+
 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")
@@ -85,7 +92,7 @@ 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!")
+    message(WARNING "Your size_t is less than 8 bytes. Decoding of huge items that would exceed the memory address space will always fail. Consider implementing a custom streaming decoder if you need to deal with huge items.")
 else()
     add_definitions(-DEIGHT_BYTE_SIZE_T)
 endif()
@@ -99,19 +106,36 @@ 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")
+                  COMMAND echo "Coverage report ready: ${CMAKE_CURRENT_BINARY_DIR}/coverage_html/index.html")
+
+add_custom_target(llvm-coverage
+                    COMMAND make -j 16
+                    COMMAND rm -rf coverage_profiles
+                    COMMAND mkdir coverage_profiles
+                    COMMAND bash -c [[ for TEST in $(ls test/*_test); do LLVM_PROFILE_FILE="coverage_profiles/$(basename -- ${TEST}).profraw" ./${TEST}; done ]]
+                    # VERBATIM makes escaping working, but breaks shell expansions, so we need to explicitly use bash
+                    COMMAND bash -c [[ llvm-profdata merge -sparse $(ls coverage_profiles/*.profraw) -o coverage_profiles/combined.profdata ]]
+                    COMMAND bash -c [[ llvm-cov show -instr-profile=coverage_profiles/combined.profdata test/*_test -format=html > coverage_profiles/report.html ]]
+                    COMMAND bash -c [[ llvm-cov report -instr-profile=coverage_profiles/combined.profdata test/*_test ]]
+                    COMMAND echo "Coverage report ready: ${CMAKE_CURRENT_BINARY_DIR}/coverage_profiles/report.html"
+                    VERBATIM)
+
 include_directories(src)
 
 
-option(COVERAGE "Enable code coverage instrumentation" OFF)
+option(c "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")
+    if(CMAKE_C_COMPILER_ID MATCHES "GNU")
+        # 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")
+    elseif(CMAKE_C_COMPILER_ID MATCHES "Clang")
+        set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fprofile-instr-generate -fcoverage-mapping")
+        set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} -fprofile-instr-generate")
+    else()
+        message(WARNING "Code coverage build not implemented for compiler ${CMAKE_C_COMPILER_ID}")
     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)
 
 
@@ -139,20 +163,20 @@ else()
     message(STATUS "LTO is not enabled")
 endif(use_lto)
 
-subdirs(src)
+add_subdirectory(src)
 if(use_lto)
     set_property(DIRECTORY src PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
 endif(use_lto)
 
 if (WITH_TESTS)
-    subdirs(test)
+    add_subdirectory(test)
     if(use_lto)
         set_property(DIRECTORY test PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
     endif(use_lto)
 endif (WITH_TESTS)
 
 if (WITH_EXAMPLES)
-    subdirs(examples)
+    add_subdirectory(examples)
     if(use_lto)
         set_property(DIRECTORY examples PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
     endif(use_lto)
diff --git a/contrib/libcbor/CMakeModules/FindCMocka.cmake b/contrib/libcbor/CMakeModules/FindCMocka.cmake
index 770b44afc426..29e57ae87f1b 100644
--- a/contrib/libcbor/CMakeModules/FindCMocka.cmake
+++ b/contrib/libcbor/CMakeModules/FindCMocka.cmake
@@ -21,7 +21,14 @@
 #=============================================================================
 #
 
+find_package(PkgConfig QUIET)
+if(PKG_CONFIG_FOUND)
+    pkg_check_modules(PC_CMOCKA QUIET cmocka)
+    set(CMOCKA_DEFINITIONS ${PC_CMOCKA_CFLAGS_OTHER})
+endif()
+
 find_path(CMOCKA_INCLUDE_DIR
+    HINTS ${PC_CMOCKA_INCLUDEDIR} ${PC_CMOCKA_INCLUDE_DIRS}
     NAMES
         cmocka.h
     PATHS
@@ -29,6 +36,7 @@ find_path(CMOCKA_INCLUDE_DIR
 )
 
 find_library(CMOCKA_LIBRARY
+    HINTS ${PC_CMOCKA_LIBDIR} ${PC_CMOCKA_LIBRARY_DIRS}
     NAMES
         cmocka cmocka_shared
     PATHS
diff --git a/contrib/libcbor/CMakeModules/JoinPaths.cmake b/contrib/libcbor/CMakeModules/JoinPaths.cmake
new file mode 100644
index 000000000000..c68d91b84dbc
--- /dev/null
+++ b/contrib/libcbor/CMakeModules/JoinPaths.cmake
@@ -0,0 +1,23 @@
+# This module provides function for joining paths
+# known from most languages
+#
+# SPDX-License-Identifier: (MIT OR CC0-1.0)
+# Copyright 2020 Jan Tojnar
+# https://github.com/jtojnar/cmake-snips
+#
+# Modelled after Python’s os.path.join
+# https://docs.python.org/3.7/library/os.path.html#os.path.join
+# Windows not supported
+function(join_paths joined_path first_path_segment)
+    set(temp_path "${first_path_segment}")
+    foreach(current_segment IN LISTS ARGN)
+        if(NOT ("${current_segment}" STREQUAL ""))
+            if(IS_ABSOLUTE "${current_segment}")
+                set(temp_path "${current_segment}")
+            else()
+                set(temp_path "${temp_path}/${current_segment}")
+            endif()
+        endif()
+    endforeach()
+    set(${joined_path} "${temp_path}" PARENT_SCOPE)
+endfunction()
diff --git a/contrib/libcbor/CONTRIBUTING.md b/contrib/libcbor/CONTRIBUTING.md
new file mode 100644
index 000000000000..cc834d21a46b
--- /dev/null
+++ b/contrib/libcbor/CONTRIBUTING.md
@@ -0,0 +1,35 @@
+# Contributing to libcbor
+
+libcbor is maintained by [@PJK](https://github.com/PJK) in his spare time on a best-effort basis.
+
+Community contributions are welcome as long as they align with the [project priorities](https://github.com/PJK/libcbor#main-features) and [goals](https://libcbor.readthedocs.io/en/latest/development.html#goals) and follow the guidelines described belows. 
+
+## Principles
+
+**Bug reports and questions:** Bug reports and specific technical questions are always welcome. Feel free to open an [issue](https://github.com/PJK/libcbor/issues).   
+
+**Incremental improvements:** Bug fixes (including build scripts, examples, test, typos, CI/CD config, etc.) and documentation improvements (fixes of typos, inaccuracies, out of date content, etc.) are always welcome. Feel free to open a [PR](https://github.com/PJK/libcbor/pulls).
+
+**New features:** I am looking to keep the scope of libcbor small. If you would like to add a feature, please open an issue with your proposal (or reach out to me privately) to discuss if the feature fits into libcbor before opening a PR.
+
+**Major changes:** Please open an issue with your proposal (or reach out to me privately) to discuss if the improvement fits into cbor before opening a PR.
+
+## Pull Request Process
+
+1. Ensure that all CI checks pass
+2. Check that the PR is complete and of good quality
+    - Include a descriptive summary of the change. If the PR addresses an open issue, please link it.
+    - Code changes: Add tests
+    - If necessary: Update documentation, including any links 
+3. Code changes: Update [the changelog](https://github.com/PJK/libcbor/blob/master/CHANGELOG.md). Do *not* change the version number.
+
+## Interactions
+
+I work on libcbor on a best effort basis. The typical response time is a few days. 
+
+If you do not receive a response in a few weeks, feel free to ping the PR or issue.
+
+## Resources
+
+- [Development documentation](https://libcbor.readthedocs.io/en/latest/development.html)
+
diff --git a/contrib/libcbor/Doxyfile b/contrib/libcbor/Doxyfile
index b197d2bcdedc..2571057646d7 100644
--- a/contrib/libcbor/Doxyfile
+++ b/contrib/libcbor/Doxyfile
@@ -1,4 +1,4 @@
-# Doxyfile 1.8.12
+# Doxyfile 1.9.6
 
 # This file describes the settings to be used by the documentation system
 # doxygen (www.doxygen.org) for a project.
@@ -12,16 +12,26 @@
 # For lists, items can also be appended using:
 # TAG += value [value, ...]
 # Values that contain spaces should be placed between quotes (\" \").
+#
+# Note:
+#
+# Use doxygen to compare the used configuration file with the template
+# configuration file:
+# doxygen -x [configFile]
+# Use doxygen to compare the used configuration file with the template
+# configuration file without replacing the environment variables or CMake type
+# replacement variables:
+# doxygen -x_noenv [configFile]
 
 #---------------------------------------------------------------------------
 # 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.
+# This tag specifies the encoding used for all characters in the configuration
+# 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
+# https://www.gnu.org/software/libiconv/ for the list of possible encodings.
 # The default value is: UTF-8.
*** 13659 LINES SKIPPED ***