This repository has been archived on 2026-09-06. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Nicolas Iooss 4682eaa1e0 Pretty: ensure recursionsLeft is not zero before decrementing it
When value_to_pretty is called with recursionsLeft=0 and an Array or Map
type, container_to_pretty is called with recursionsLeft - 1 = -1. This
breaks the recursion limit check.

In practice, this can be triggered with a CBOR data containing 1023
Arrays, a Tag and many more Arrays:

    $ python3 -c 'import sys;sys.stdout.buffer.write(b"\x9f" * 1023 + b"\xc0\x9f" + b"\x9f" * 100000 + b"\xff" * 101024)' | ./bin/cbordump
    Segmentation fault (core dumped)

This segmentation fault is due to the stack growing too much, due to the
quantity of recursive calls.

Fix this by reporting a proper error when recursionsLeft <= 0, instead
of when recursionsLeft == 0. The same input now produces:

    [_ [_ [_ ... [_ 0([
    -: internal error: too many nested containers found in recursive function
    _ <nesting too deep, recursion stopped>

Moreover, using fewer nested arrays works fine:

    $ python3 -c 'import sys;sys.stdout.buffer.write(b"\x9f" * 1023 + b"\xc0\x9f" + b"\x9f" * 1024 + b"\xff" * 2048)' |./bin/cbordump
    [_ [_ [_ ... [_ 0([_ <nesting too deep, recursion stopped>])] ... ]]]

Also modify the test when formatting CborTagType to ensure
value_to_pretty is never called with a negative recursionsLeft.
2025-03-18 10:49:39 -07:00
2025-03-12 16:49:17 -07:00
2025-03-12 16:49:17 -07:00
2016-08-04 14:25:32 -07:00
2018-02-07 10:40:52 -08:00
2017-07-26 10:29:17 -07:00
2017-12-06 18:25:51 -08:00
2021-09-03 11:56:36 -07:00

Concise Binary Object Representation (CBOR) Library
---------------------------------------------------

To build TinyCBOR:

  make

If you want to change the compiler or pass extra compiler flags:

  make CC=clang CFLAGS="-m32 -Oz" LDFLAGS="-m32"

Documentation: https://intel.github.io/tinycbor/current/

S
Description
[ARCHIVE] GOLEM lab historic — frozen 2026-09-06
Readme MIT
891 KiB
Languages
C 50.3%
C++ 45.9%
CMake 2.1%
Perl 1.3%
Shell 0.3%
Other 0.1%