<feed xmlns='http://www.w3.org/2005/Atom'>
<title>libubox/blobmsg.h, branch master</title>
<subtitle>C utility functions for OpenWrt</subtitle>
<id>https://git-03.infra.openwrt.org/project/libubox/atom?h=master</id>
<link rel='self' href='https://git-03.infra.openwrt.org/project/libubox/atom?h=master'/>
<link rel='alternate' type='text/html' href='https://git-03.infra.openwrt.org/project/libubox/'/>
<updated>2025-11-14T15:14:50Z</updated>
<entry>
<title>blobmsg: refactor blobmsg_cast_u64/s64</title>
<updated>2025-11-14T15:14:50Z</updated>
<author>
<name>Álvaro Fernández Rojas</name>
</author>
<published>2025-11-10T16:36:59Z</published>
<link rel='alternate' type='text/html' href='https://git-03.infra.openwrt.org/project/libubox/commit/?id=a75209f62982f7218f73b9b4fd9b705e19f5f94a'/>
<id>urn:sha1:a75209f62982f7218f73b9b4fd9b705e19f5f94a</id>
<content type='text'>
Instead of calling blobmsg_type() for each if/else block, just call it
once and use it with a switch.

Link: https://github.com/openwrt/libubox/pull/24
Signed-off-by: Álvaro Fernández Rojas &lt;noltari@gmail.com&gt;
</content>
</entry>
<entry>
<title>blobmsg: add blobmsg_parse_array_attr</title>
<updated>2023-01-03T09:43:49Z</updated>
<author>
<name>Felix Fietkau</name>
</author>
<published>2023-01-03T09:43:44Z</published>
<link rel='alternate' type='text/html' href='https://git-03.infra.openwrt.org/project/libubox/commit/?id=eac92a4d5d82eb31e712157e7eb425af728b2c43'/>
<id>urn:sha1:eac92a4d5d82eb31e712157e7eb425af728b2c43</id>
<content type='text'>
Wrapper around blobmsg_parse_array, similar to blobmsg_parse_attr

Signed-off-by: Felix Fietkau &lt;nbd@nbd.name&gt;
</content>
</entry>
<entry>
<title>blobmsg: add blobmsg_parse_attr function</title>
<updated>2022-11-23T11:30:10Z</updated>
<author>
<name>Felix Fietkau</name>
</author>
<published>2022-11-23T11:29:19Z</published>
<link rel='alternate' type='text/html' href='https://git-03.infra.openwrt.org/project/libubox/commit/?id=b09b316aeaf6282bf2d2f7df9d2cc2cdf3977691'/>
<id>urn:sha1:b09b316aeaf6282bf2d2f7df9d2cc2cdf3977691</id>
<content type='text'>
This allows turning the common pattern of:
  blobmsg_parse(policy, ARRAY_SIZE(policy), tb, blobmsg_data(data), blobmsg_len(data));

into:
  blobmsg_parse_attr(policy, ARRAY_SIZE(policy), tb, data);

Signed-off-by: Felix Fietkau &lt;nbd@nbd.name&gt;
</content>
</entry>
<entry>
<title>blobmsg: work around false positive gcc -Warray-bounds warnings</title>
<updated>2022-05-15T11:42:58Z</updated>
<author>
<name>Felix Fietkau</name>
</author>
<published>2022-05-15T11:42:56Z</published>
<link rel='alternate' type='text/html' href='https://git-03.infra.openwrt.org/project/libubox/commit/?id=d2223ef9da7172a84d1508733dc58840e1381e3c'/>
<id>urn:sha1:d2223ef9da7172a84d1508733dc58840e1381e3c</id>
<content type='text'>
Using the return value of blobmsg_name as input argument to strcpy can lead
to warnings like these:

error: 'strcpy' offset 6 from the object at 'cur' is out of the bounds of referenced subobject 'name' with type 'uint8_t[]' {aka 'unsigned char[]'} at offset 6 [-Werror=array-bounds]

Fix this by replacing hdr-&gt;name with the equivalent hdr + 1

Signed-off-by: Felix Fietkau &lt;nbd@nbd.name&gt;
</content>
</entry>
<entry>
<title>libubox: fix BLOBMSG_CAST_INT64 (do not override BLOBMSG_TYPE_DOUBLE)</title>
<updated>2021-03-02T12:06:24Z</updated>
<author>
<name>Peter Seiderer</name>
</author>
<published>2021-02-26T19:24:20Z</published>
<link rel='alternate' type='text/html' href='https://git-03.infra.openwrt.org/project/libubox/commit/?id=2e52c7e9a90ab7ba1cf9d2986d1505ca5d184698'/>
<id>urn:sha1:2e52c7e9a90ab7ba1cf9d2986d1505ca5d184698</id>
<content type='text'>
Commit 9e52171 ('blobmsg: introduce BLOBMSG_CAST_INT64') broke
blobmsg_parse() for BLOBMSG_TYPE_DOUBLE.

This is because the enum definition leads to the following double
define for BLOBMSG_CAST_INT64/BLOBMSG_TYPE_DOUBLE as value 8.

Tested with:

	$ cat test-enum-001.c
  #include &lt;stdio.h&gt;

  enum blobmsg_type {
  	BLOBMSG_TYPE_UNSPEC,
  	BLOBMSG_TYPE_ARRAY,
  	BLOBMSG_TYPE_TABLE,
  	BLOBMSG_TYPE_STRING,
  	BLOBMSG_TYPE_INT64,
  	BLOBMSG_TYPE_INT32,
  	BLOBMSG_TYPE_INT16,
  	BLOBMSG_TYPE_INT8,
  	BLOBMSG_TYPE_DOUBLE,
  	__BLOBMSG_TYPE_LAST,
  	BLOBMSG_TYPE_LAST = __BLOBMSG_TYPE_LAST - 1,
  	BLOBMSG_TYPE_BOOL = BLOBMSG_TYPE_INT8,
  	BLOBMSG_CAST_INT64,
  };

  int main(int artc, char* argv[]) {
  	printf("BLOBMSG_TYPE_UNSPEC: %d\n", BLOBMSG_TYPE_UNSPEC);
  	printf("BLOBMSG_TYPE_ARRAY: %d\n", BLOBMSG_TYPE_ARRAY);
  	printf("BLOBMSG_TYPE_TABLE: %d\n", BLOBMSG_TYPE_TABLE);
  	printf("BLOBMSG_TYPE_STRING: %d\n", BLOBMSG_TYPE_STRING);
  	printf("BLOBMSG_TYPE_INT64: %d\n", BLOBMSG_TYPE_INT64);
  	printf("BLOBMSG_TYPE_INT32: %d\n", BLOBMSG_TYPE_INT32);
  	printf("BLOBMSG_TYPE_INT16: %d\n", BLOBMSG_TYPE_INT16);
  	printf("BLOBMSG_TYPE_INT8: %d\n", BLOBMSG_TYPE_INT8);
  	printf("BLOBMSG_TYPE_DOUBLE: %d\n", BLOBMSG_TYPE_DOUBLE);
  	printf("__BLOBMSG_TYPE_LAST: %d\n", __BLOBMSG_TYPE_LAST);
  	printf("BLOBMSG_TYPE_LAST: %d\n", BLOBMSG_TYPE_LAST);
  	printf("BLOBMSG_TYPE_BOOL: %d\n", BLOBMSG_TYPE_BOOL);
  	printf("BLOBMSG_CAST_INT64: %d\n", BLOBMSG_CAST_INT64);
  	return 0;
  }

	$ gcc test-enum-001.c

	$ ./a.out
  BLOBMSG_TYPE_UNSPEC: 0
  BLOBMSG_TYPE_ARRAY: 1
  BLOBMSG_TYPE_TABLE: 2
  BLOBMSG_TYPE_STRING: 3
  BLOBMSG_TYPE_INT64: 4
  BLOBMSG_TYPE_INT32: 5
  BLOBMSG_TYPE_INT16: 6
  BLOBMSG_TYPE_INT8: 7
  BLOBMSG_TYPE_DOUBLE: 8
  __BLOBMSG_TYPE_LAST: 9
  BLOBMSG_TYPE_LAST: 8
  BLOBMSG_TYPE_BOOL: 7
  BLOBMSG_CAST_INT64: 8

Fix this by changing the enum defintion to assign BLOBMSG_CAST_INT64 to
the unique value 9.

Signed-off-by: Peter Seiderer &lt;ps.report@gmx.net&gt;
</content>
</entry>
<entry>
<title>blobmsg: introduce BLOBMSG_CAST_INT64</title>
<updated>2020-08-06T13:29:36Z</updated>
<author>
<name>Daniel Golle</name>
</author>
<published>2020-08-04T00:27:09Z</published>
<link rel='alternate' type='text/html' href='https://git-03.infra.openwrt.org/project/libubox/commit/?id=9e52171d70def760a6949676800d0b73f85ee22d'/>
<id>urn:sha1:9e52171d70def760a6949676800d0b73f85ee22d</id>
<content type='text'>
When dealing with 64-bit integers in JSON documents, blobmsg_parse
becomes useless as blobmsg-json only uses BLOBMSG_TYPE_INT64 if the
value exceeds the range of a 32-bit integer, otherwise
BLOBMSG_TYPE_INT32 is used. This is because blobmsg-json parses the
JSON document ad-hoc without knowing the schema in advance and hence
a result of the design of blobmsg-json (and the absence of JSON
schema definitions).
In practise, this made code less readable as instead of using
blobmsg_parse() one had to to deal with *all* attributes manually just
to catch fields which can be both, BLOBMSG_TYPE_INT32 or
BLOBMSG_TYPE_INT64, but are always dealt with as uint64_t in code as
they potentially could exceed the 32-bit range.

To resolve this issue, introduce as special wildcard attribute
type BLOBMSG_CAST_INT64 which should only be used in policies used
by blobmsg_parse(). If used for an attribute in the policy,
blobmsg_parse shall accept all integer types and allow the user
to retrieve the value using the uint64_t blobmsg_cast_u64() and
int64_t blobmsg_cast_s64() functions which is also introduced by this
commit.

Signed-off-by: Daniel Golle &lt;daniel@makrotopia.org&gt;
</content>
</entry>
<entry>
<title>blobmsg: drop old comment about json formatting functions</title>
<updated>2020-05-26T08:52:32Z</updated>
<author>
<name>Rafał Miłecki</name>
</author>
<published>2020-05-26T08:50:58Z</published>
<link rel='alternate' type='text/html' href='https://git-03.infra.openwrt.org/project/libubox/commit/?id=e85cb739766d00977a08cce98f161976da5fbefc'/>
<id>urn:sha1:e85cb739766d00977a08cce98f161976da5fbefc</id>
<content type='text'>
Those functions were moved out of blobmsg.h.

Fixes: 0918243e90e6 ("move json formatting to the blobmsg_json library")
Signed-off-by: Rafał Miłecki &lt;rafal@milecki.pl&gt;
</content>
</entry>
<entry>
<title>blobmsg: reuse blobmsg_namelen in blobmsg_data</title>
<updated>2019-12-25T09:31:58Z</updated>
<author>
<name>Petr Štetiar</name>
</author>
<published>2019-12-12T15:42:39Z</published>
<link rel='alternate' type='text/html' href='https://git-03.infra.openwrt.org/project/libubox/commit/?id=86f6a5b8d1f160cc6f278f08f69d2c3d0f90b43c'/>
<id>urn:sha1:86f6a5b8d1f160cc6f278f08f69d2c3d0f90b43c</id>
<content type='text'>
Move blobmsg_namelen into header file so it's possible to reuse it in
blobmsg_data.

Signed-off-by: Petr Štetiar &lt;ynezz@true.cz&gt;
</content>
</entry>
<entry>
<title>blobmsg: add _len variants for all attribute checking methods</title>
<updated>2019-12-25T09:31:58Z</updated>
<author>
<name>Tobias Schramm</name>
</author>
<published>2018-11-15T02:42:48Z</published>
<link rel='alternate' type='text/html' href='https://git-03.infra.openwrt.org/project/libubox/commit/?id=b0e21553ae8c58d5db8103a0ea4d6095c6e4fe07'/>
<id>urn:sha1:b0e21553ae8c58d5db8103a0ea4d6095c6e4fe07</id>
<content type='text'>
Introduce _len variants of blobmsg attribute checking functions which
aims to provide safer implementation as those functions should limit all
memory accesses performed on the blob to the range [attr, attr + len]
(upper bound non inclusive) and thus should be suited for checking of
untrusted blob attributes.

While at it add some comments in order to make it clear.

Signed-off-by: Tobias Schramm &lt;tobleminer@gmail.com&gt;
[_safe -&gt; _len, blobmsg_check_array_len fix, commit subject/desc facelift]
Signed-off-by: Petr Štetiar &lt;ynezz@true.cz&gt;
</content>
</entry>
<entry>
<title>Replace use of blobmsg_check_attr by blobmsg_check_attr_len</title>
<updated>2019-12-25T09:31:58Z</updated>
<author>
<name>Tobias Schramm</name>
</author>
<published>2018-11-13T03:16:12Z</published>
<link rel='alternate' type='text/html' href='https://git-03.infra.openwrt.org/project/libubox/commit/?id=cd3059796a576673d4af696c8b696ab5de729a3c'/>
<id>urn:sha1:cd3059796a576673d4af696c8b696ab5de729a3c</id>
<content type='text'>
blobmsg_check_attr_len adds a length limit specifying the max offset
from attr that can be read safely.

Signed-off-by: Tobias Schramm &lt;tobleminer@gmail.com&gt;
[rebased and reworked, line wrapped commit message, _safe -&gt; _len]
Signed-off-by: Petr Štetiar &lt;ynezz@true.cz&gt;
</content>
</entry>
</feed>
