C utility functions for OpenWRT libraries
Find a file
Peter Seiderer 2e52c7e9a9 libubox: fix BLOBMSG_CAST_INT64 (do not override BLOBMSG_TYPE_DOUBLE)
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 <stdio.h>

  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 <ps.report@gmx.net>
2021-03-02 12:06:24 +00:00
examples examples/lua: attempt to highlight some traps 2020-07-11 11:15:12 +02:00
lua lua/uloop: fd_add: use absolute indices for arguments 2020-07-11 11:15:12 +02:00
sh sh/jshn.sh: add json_for_each_item() 2018-02-08 12:15:20 +01:00
tests tests: add fuzzer seed file for crash in blob_len 2020-05-26 09:48:07 +02:00
.gitignore examples: add shunit2 tests for json_script 2016-02-20 13:36:08 +01:00
.gitlab-ci.yml add cram based unit tests 2019-11-24 13:26:58 +01:00
assert.h add assert.h component 2019-11-24 13:26:58 +01:00
avl-cmp.c avl: add blob comparator function 2016-07-29 10:58:55 +02:00
avl-cmp.h avl: add blob comparator function 2016-07-29 10:58:55 +02:00
avl.c avl: guard against theoretical null pointer dereference 2019-11-24 13:26:58 +01:00
avl.h switch from typeof to the more portable __typeof__ 2018-04-07 15:21:33 +02:00
base64.c base64: fix possible null pointer dereference 2019-11-24 13:26:58 +01:00
blob.c blob: make blob_parse_untrusted more permissive 2020-05-24 16:54:37 +02:00
blob.h Ensure blob_attr length check does not perform out of bounds reads 2019-12-25 10:31:58 +01:00
blobmsg.c blobmsg: introduce BLOBMSG_CAST_INT64 2020-08-06 14:29:36 +01:00
blobmsg.h libubox: fix BLOBMSG_CAST_INT64 (do not override BLOBMSG_TYPE_DOUBLE) 2021-03-02 12:06:24 +00:00
blobmsg_json.c blobmsg_json: prefer snprintf usage 2020-01-20 16:54:10 +01:00
blobmsg_json.h blobmsg_json: add new functions blobmsg_format_json_value* 2016-07-02 10:10:08 +02:00
CMakeLists.txt cmake: add a possibility to set library version 2020-01-20 16:54:10 +01:00
jshn.c jshn: prefer snprintf usage 2020-01-20 16:54:10 +01:00
json_script.c iron out all extra compiler warnings 2019-11-20 14:34:01 +01:00
json_script.h json_script: add support for aborting script processing 2015-11-06 22:58:15 +01:00
kvlist.c Fix various memory management issues 2016-06-26 12:53:51 +02:00
kvlist.h kvlist: add static initializer macros 2016-10-24 12:34:09 +02:00
list.h switch from typeof to the more portable __typeof__ 2018-04-07 15:21:33 +02:00
md5.c md5: add "const" qualifier to the "file" argument 2017-03-20 12:44:46 +01:00
md5.h md5: add "const" qualifier to the "file" argument 2017-03-20 12:44:46 +01:00
runqueue.c libubox: runqueue: fix use-after-free bug 2020-05-21 15:58:46 +02:00
runqueue.h libubox: runqueue: fix use-after-free bug 2020-05-21 15:58:46 +02:00
safe_list.c runqueue: add a function that allows adding jobs to the front of the runqueue 2013-11-18 12:25:21 +01:00
safe_list.h runqueue: add a function that allows adding jobs to the front of the runqueue 2013-11-18 12:25:21 +01:00
ulog.c blobmsg/ulog: fix format string compiler warnings 2019-12-07 23:47:03 +01:00
ulog.h libubox: add format string checking to ulog() 2019-06-16 16:29:47 +02:00
uloop-epoll.c uloop: remove useless epoll data assignment 2016-12-12 12:24:14 +01:00
uloop-kqueue.c uloop: use a waker for notifying sigchld and loop cancel events 2016-06-15 11:54:37 +02:00
uloop.c uloop: make SIGCHLD signal handling optional 2017-09-29 13:37:17 +02:00
uloop.h uloop: allow specifying a timeout for uloop_run() 2017-06-01 11:24:44 +02:00
usock.c usock: implement usock_inet_timeout() with RFC6555 support 2016-01-28 12:07:25 +01:00
usock.h usock: implement usock_inet_timeout() with RFC6555 support 2016-01-28 12:07:25 +01:00
ustream-fd.c ustream-fd: handle ENOTCONN for read/write on not-yet-connected sockets 2016-01-15 21:35:48 +01:00
ustream.c Fix various memory management issues 2016-06-26 12:53:51 +02:00
ustream.h ustream: Add format string checks to ustream_(v)printf() 2019-06-16 16:30:01 +02:00
utils.c utils: simplify mkdir_p boolean conditions 2020-12-13 12:05:45 +00:00
utils.h utils: introduce mkdir_p 2020-12-12 22:50:50 +00:00
vlist.c vlist: constify key argument to vlist_add 2013-10-05 21:40:04 +02:00
vlist.h vlist: add more macros for loop iteration 2019-10-29 13:07:38 +00:00