<feed xmlns='http://www.w3.org/2005/Atom'>
<title>libubox/tests/cram, branch master</title>
<subtitle>C utility functions for OpenWrt</subtitle>
<id>https://git.openwrt.org/project/libubox/atom?h=master</id>
<link rel='self' href='https://git.openwrt.org/project/libubox/atom?h=master'/>
<link rel='alternate' type='text/html' href='https://git.openwrt.org/project/libubox/'/>
<updated>2026-05-03T20:17:39Z</updated>
<entry>
<title>blobmsg_json: fix double format string to avoid truncation and data loss</title>
<updated>2026-05-03T20:17:39Z</updated>
<author>
<name>Hauke Mehrtens</name>
</author>
<published>2026-04-16T20:16:42Z</published>
<link rel='alternate' type='text/html' href='https://git.openwrt.org/project/libubox/commit/?id=23c6618a5b9088644bb6b509c83f4f88ee8998d3'/>
<id>urn:sha1:23c6618a5b9088644bb6b509c83f4f88ee8998d3</id>
<content type='text'>
Using %lf (= %f) with the default precision of 6 fractional decimal
digits requires up to 317 characters for negative values close to
-DBL_MAX (1 sign + 309 integer digits + 1 decimal point + 6 fraction
digits + NUL), but buf[] only holds 317 bytes, leaving no room for the
NUL terminator — snprintf truncates the last digit silently.

Additionally, 6 fractional digits do not give round-trip accuracy for
IEEE 754 doubles; 17 significant digits (%.17g) are required.

Switch to %.17g which uses scientific notation for very large or small
values, keeping the output well within the buffer, and guarantees
round-trip accuracy for all finite doubles.

Update the cram fixtures test_blobmsg.t and test_blobmsg_types.t to
match the new output. The previous fixtures encoded the buggy
behaviour: DBL_MIN serialised as "0.000000" and was silently flattened
to zero on the JSON round-trip, while DBL_MAX produced a 309-digit
decimal string.

Link: https://github.com/openwrt/libubox/pull/42
Co-Authored-By: Claude Sonnet 4.6 &lt;noreply@anthropic.com&gt;
Signed-off-by: Hauke Mehrtens &lt;hauke@hauke-m.de&gt;
</content>
</entry>
<entry>
<title>tests: add blob-buffer overflow test</title>
<updated>2021-04-29T13:34:21Z</updated>
<author>
<name>Zefir Kurtisi</name>
</author>
<published>2021-04-23T17:48:00Z</published>
<link rel='alternate' type='text/html' href='https://git.openwrt.org/project/libubox/commit/?id=a0dbcf8b8f966ce8a358afe555bb75401ef1e9be'/>
<id>urn:sha1:a0dbcf8b8f966ce8a358afe555bb75401ef1e9be</id>
<content type='text'>
The blob buffer has no limitation in place
to prevent buflen to exceed maximum size.

This commit adds a test to demonstrate how
a blob increases past the maximum allowd
size of 16MB. It continuously adds chunks
of 64KB and with the 255th one blob_add()
returns a valid attribute pointer but the
blob's buflen does not increase.

The test is used to demonstrate the
failure, which is fixed with a follow-up
commit.

Signed-off-by: Zefir Kurtisi &lt;zefir.kurtisi@gmail.com&gt;
[adjusted test case for cram usage]
Signed-off-by: Petr Štetiar &lt;ynezz@true.cz&gt;
</content>
</entry>
<entry>
<title>libubox: tests: add more blobmsg/json test cases</title>
<updated>2021-03-09T20:53:14Z</updated>
<author>
<name>Peter Seiderer</name>
</author>
<published>2021-03-06T10:54:50Z</published>
<link rel='alternate' type='text/html' href='https://git.openwrt.org/project/libubox/commit/?id=551d75b5662cccd0466b990d58136bdf799a804d'/>
<id>urn:sha1:551d75b5662cccd0466b990d58136bdf799a804d</id>
<content type='text'>
* add mixed int/double tests
 * add blobmsg_cast_u64/blobmsg_cast_s64 tests

Signed-off-by: Peter Seiderer &lt;ps.report@gmx.net&gt;
</content>
</entry>
<entry>
<title>tests: cram: test_base64: really fix failing tests</title>
<updated>2021-03-03T17:26:52Z</updated>
<author>
<name>Petr Štetiar</name>
</author>
<published>2021-03-03T14:37:52Z</published>
<link rel='alternate' type='text/html' href='https://git.openwrt.org/project/libubox/commit/?id=4d8995e91d56ee7629842afee2194bfe4c89854c'/>
<id>urn:sha1:4d8995e91d56ee7629842afee2194bfe4c89854c</id>
<content type='text'>
Remove the checks for 'Aborted (core dumped)' message altogether as it's
not reliable and not portable.

References: https://gitlab.com/openwrt/project/libubox/-/jobs/1070226897
Signed-off-by: Petr Štetiar &lt;ynezz@true.cz&gt;
</content>
</entry>
<entry>
<title>tests: cram: test_base64: fix failing tests</title>
<updated>2021-03-03T13:37:09Z</updated>
<author>
<name>Petr Štetiar</name>
</author>
<published>2021-03-03T12:49:27Z</published>
<link rel='alternate' type='text/html' href='https://git.openwrt.org/project/libubox/commit/?id=870acee325fe61267ac4ec1f0c6cba80b954cce5'/>
<id>urn:sha1:870acee325fe61267ac4ec1f0c6cba80b954cce5</id>
<content type='text'>
Seems like latest version of llvm compiler/sanitizer has changed
behaviour during crash so `Aborted (core dumped)` is now printed to
stdout.

Fixes following issue:

 --- /builds/openwrt/project/libubox/tests/cram/test_base64.t
 +++ /builds/openwrt/project/libubox/tests/cram/test_base64.t.err
 @@ -49,9 +49,7 @@
    b64_encode: Assertion `dest &amp;&amp; targsize &gt; 0' failed.

    $ test-b64_decode-san 2&gt; output.log; check
 -  Aborted (core dumped)
    b64_decode: Assertion `dest &amp;&amp; targsize &gt; 0' failed.

    $ test-b64_encode-san 2&gt; output.log; check
 -  Aborted (core dumped)
    b64_encode: Assertion `dest &amp;&amp; targsize &gt; 0' failed.

References: https://gitlab.com/openwrt/project/libubox/-/jobs/1069840314
Signed-off-by: Petr Štetiar &lt;ynezz@true.cz&gt;
</content>
</entry>
<entry>
<title>tests: add fuzzer seed file for crash in blob_len</title>
<updated>2020-05-26T07:48:07Z</updated>
<author>
<name>Petr Štetiar</name>
</author>
<published>2020-05-26T07:22:13Z</published>
<link rel='alternate' type='text/html' href='https://git.openwrt.org/project/libubox/commit/?id=cf2e8eb485abc30ed8acc51ba5cb50d2bbc8e3d1'/>
<id>urn:sha1:cf2e8eb485abc30ed8acc51ba5cb50d2bbc8e3d1</id>
<content type='text'>
Following regression was introduced in commit 5e75160f4878 ("blobmsg:
fix attrs iteration in the blobmsg_check_array_len()"):

 Thread 1 "test-fuzz" received signal SIGSEGV, Segmentation fault.
  in blob_len (attr=0x6020000100d4) at libubox/blob.h:102
  102             return (be32_to_cpu(attr-&gt;id_len) &amp; BLOB_ATTR_LEN_MASK) - sizeof(struct blob_attr);

 blob_len (attr=0x6020000100d4) at /libubox/blob.h:102
 blob_raw_len (attr=0x6020000100d4) at /libubox/blob.h:111
 blob_pad_len (attr=0x6020000100d4) at /libubox/blob.h:120
 blobmsg_check_array_len (attr=0x6020000000d0, type=0, blob_len=10) at /libubox/blobmsg.c:145
 fuzz_blobmsg_parse (data=0x6020000000d0 "\001\004", size=10) at /libubox/tests/fuzz/test-fuzz.c:57

Signed-off-by: Petr Štetiar &lt;ynezz@true.cz&gt;
</content>
</entry>
<entry>
<title>blob: make blob_parse_untrusted more permissive</title>
<updated>2020-05-24T14:54:37Z</updated>
<author>
<name>Matthias Schiffer</name>
</author>
<published>2020-05-16T20:22:10Z</published>
<link rel='alternate' type='text/html' href='https://git.openwrt.org/project/libubox/commit/?id=86818eaa976b0d396c1eabfdce307c33a48c0309'/>
<id>urn:sha1:86818eaa976b0d396c1eabfdce307c33a48c0309</id>
<content type='text'>
Some tools like ucert use concatenations of multiple blobs. Account for
this case by allowing the underlying buffer length to be greater than
the blob length.

Signed-off-by: Matthias Schiffer &lt;mschiffer@universe-factory.net&gt;
</content>
</entry>
<entry>
<title>libubox: runqueue: fix use-after-free bug</title>
<updated>2020-05-21T13:58:46Z</updated>
<author>
<name>Alban Bedel</name>
</author>
<published>2020-04-23T03:35:23Z</published>
<link rel='alternate' type='text/html' href='https://git.openwrt.org/project/libubox/commit/?id=89fb6136ad7484e4e8f9b618e530e098cf573665'/>
<id>urn:sha1:89fb6136ad7484e4e8f9b618e530e098cf573665</id>
<content type='text'>
Fixes a use-after-free bug in runqueue_task_kill():

 Invalid read of size 8
    at runqueue_task_kill (runqueue.c:200)
    by uloop_process_timeouts (uloop.c:505)
    by uloop_run_timeout (uloop.c:542)
    by uloop_run (uloop.h:111)
    by main (tests/test-runqueue.c:126)
  Address 0x5a4b058 is 24 bytes inside a block of size 208 free'd
    at free
    by runqueue_task_complete (runqueue.c:234)
    by runqueue_task_kill (runqueue.c:199)
    by uloop_process_timeouts (uloop.c:505)
    by uloop_run_timeout (uloop.c:542)
    by uloop_run (uloop.h:111)
    by main (tests/test-runqueue.c:126)
  Block was alloc'd at
    at calloc
    by add_sleeper (tests/test-runqueue.c:101)
    by main (tests/test-runqueue.c:123)

Since commit 11e8afea (runqueue should call the complete handler from
more places) the call to the complete() callback has been moved to
runqueue_task_complete().  However in runqueue_task_kill()
runqueue_task_complete() is called before the kill() callback.  This
will result in a use after free if the complete() callback frees the
task struct.

Furthermore runqueue_start_next() is already called at the end of
runqueue_task_complete(), so there is no need to call it again in
runqueue_task_kill().

The issue was that the _complete() callback frees the memory used by the
task struct, which is then read after the _complete() callback returns.

Ref: FS#3016
Signed-off-by: Alban Bedel &lt;albeu@free.fr&gt;
[initial test case, kill cb comment fix]
Signed-off-by: Chris Nisbet &lt;nischris@gmail.com&gt;
[testcase improvements and commit subject/description tweaks]
Signed-off-by: Petr Štetiar &lt;ynezz@true.cz&gt;
</content>
</entry>
<entry>
<title>tests: list: add test case for list_empty iterator</title>
<updated>2020-05-21T11:43:00Z</updated>
<author>
<name>Petr Štetiar</name>
</author>
<published>2019-12-19T10:49:39Z</published>
<link rel='alternate' type='text/html' href='https://git.openwrt.org/project/libubox/commit/?id=7c4ef0d9ae28525f70c09ff77b71015408bc3e62'/>
<id>urn:sha1:7c4ef0d9ae28525f70c09ff77b71015408bc3e62</id>
<content type='text'>
Increasing unit testing code coverage.

Signed-off-by: Petr Štetiar &lt;ynezz@true.cz&gt;
</content>
</entry>
<entry>
<title>tests: blobmsg: add test case</title>
<updated>2020-02-27T20:56:20Z</updated>
<author>
<name>Chris Nisbet</name>
</author>
<published>2020-02-12T08:08:44Z</published>
<link rel='alternate' type='text/html' href='https://git.openwrt.org/project/libubox/commit/?id=7da66430de3fc235bfc6ebb0b85fb90ea246138d'/>
<id>urn:sha1:7da66430de3fc235bfc6ebb0b85fb90ea246138d</id>
<content type='text'>
 * add a test for blobmsg_check_array() to test an array with a string in it

This test was added in conjunction with a change to blobmsg_check_array() to
get it to pass the length obtained from blob_len() rather than blobmsg_len().

Signed-off-by: Chris Nisbet &lt;nischris@gmail.com&gt;
</content>
</entry>
</feed>
