Commit graph

16 commits

Author SHA1 Message Date
Felix Fietkau
cfa372ff8a blobmsg: implicitly reserve space for 0-terminator in string buf alloc
It may not be clear to all users of this API if the provided maxlen argument
refers to the maximum string length or the maximum buffer size.
In order to improve safety and convenience of this API, make it refer to
the maximum string length.

Signed-off-by: Felix Fietkau <nbd@nbd.name>
2022-05-12 13:26:29 +02:00
Felix Fietkau
b14c468861 json_script: fix unannotated fall-through warning
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2021-05-16 18:07:26 +02:00
Petr Štetiar
6228df9de9 iron out all extra compiler warnings
gcc-9 on x86/64 has reported following issues:

 base64.c:173:17: error: comparison of integer expressions of different signedness: ‘int’ and ‘size_t’ {aka ‘long unsigned int’} [-Werror=sign-compare]
 base64.c:230:18: error: comparison of integer expressions of different signedness: ‘int’ and ‘size_t’ {aka ‘long unsigned int’} [-Werror=sign-compare]
 base64.c:238:18: error: comparison of integer expressions of different signedness: ‘int’ and ‘size_t’ {aka ‘long unsigned int’} [-Werror=sign-compare]
 base64.c:242:22: error: comparison of integer expressions of different signedness: ‘int’ and ‘size_t’ {aka ‘long unsigned int’} [-Werror=sign-compare]
 base64.c:252:18: error: comparison of integer expressions of different signedness: ‘int’ and ‘size_t’ {aka ‘long unsigned int’} [-Werror=sign-compare]
 base64.c:256:22: error: comparison of integer expressions of different signedness: ‘int’ and ‘size_t’ {aka ‘long unsigned int’} [-Werror=sign-compare]
 base64.c:266:18: error: comparison of integer expressions of different signedness: ‘int’ and ‘size_t’ {aka ‘long unsigned int’} [-Werror=sign-compare]
 base64.c:315:27: error: comparison of integer expressions of different signedness: ‘int’ and ‘size_t’ {aka ‘long unsigned int’} [-Werror=sign-compare]
 base64.c:329:15: error: comparison of integer expressions of different signedness: ‘int’ and ‘size_t’ {aka ‘long unsigned int’} [-Werror=sign-compare]
 blob.c:207:11: error: comparison of integer expressions of different signedness: ‘unsigned int’ and ‘int’ [-Werror=sign-compare]
 blob.c:210:11: error: comparison of integer expressions of different signedness: ‘unsigned int’ and ‘int’ [-Werror=sign-compare]
 blob.c:243:31: error: comparison of integer expressions of different signedness: ‘int’ and ‘unsigned int’ [-Werror=sign-compare]
 blob.c:246:31: error: comparison of integer expressions of different signedness: ‘int’ and ‘unsigned int’ [-Werror=sign-compare]
 blob.h:245:37: error: comparison of integer expressions of different signedness: ‘unsigned int’ and ‘int’ [-Werror=sign-compare]
 blob.h:253:37: error: comparison of integer expressions of different signedness: ‘unsigned int’ and ‘int’ [-Werror=sign-compare]
 blobmsg.h:269:37: error: comparison of integer expressions of different signedness: ‘unsigned int’ and ‘int’ [-Werror=sign-compare]
 blobmsg_json.c:155:10: error: comparison of integer expressions of different signedness: ‘int’ and ‘size_t’ {aka ‘long unsigned int’} [-Werror=sign-compare]
 examples/../blob.h:245:37: error: comparison of integer expressions of different signedness: ‘unsigned int’ and ‘int’ [-Werror=sign-compare]
 examples/../blobmsg.h:269:37: error: comparison of integer expressions of different signedness: ‘unsigned int’ and ‘int’ [-Werror=sign-compare]
 json_script.c:590:7: error: this statement may fall through [-Werror=implicit-fallthrough=]

Signed-off-by: Petr Štetiar <ynezz@true.cz>
2019-11-20 14:34:01 +01:00
Denis Osvald
fa9937cc4f json_script: enable custom expr handler callback
This wires in custom expression handler functionality, which was present
in json script since the original version, but never used.

Signed-off-by: Denis Osvald <denis.osvald@sartura.hr>
Signed-off-by: Felix Fietkau <nbd@nbd.name> [error handling fix]
2017-06-01 11:23:16 +02:00
Matthias Schiffer
1f019ceea1 Fix various memory management issues
Consistently handle allocation failures. Some functions are changed to
return bool or int instead of void to allow returning an error.

Also fix a buffer size miscalculation in lua/uloop and use _exit() instead
of exit() on errors after forking.

Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net>
2016-06-26 12:53:51 +02:00
Yousong Zhou
02db6d71b6 json_script: add "isdir" support
Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
2016-02-20 13:36:08 +01:00
Felix Fietkau
10429bccd0 json_script: allow non-string types in command arguments
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2015-11-08 20:19:08 +01:00
Felix Fietkau
3d45c47752 json_script: add support for aborting script processing
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2015-11-06 22:58:15 +01:00
Yousong Zhou
13b5c1d4ca json_script: fix logic invert of handle_expr_not().
Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
2014-12-22 15:46:21 +01:00
Yousong Zhou
0d22684faa json_script: remove unneed argument check before calling __json_script_file_free().
NULL check is present at the begining of function body.

Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
2014-12-11 17:59:22 +01:00
Yousong Zhou
30e6cca939 json_script: fix eval_string().
- Fix handling of "%%".
 - Fix length requirement when calling blobmsg_realloc_string_buffer().

Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
2014-12-11 17:59:02 +01:00
Felix Fietkau
1344d20ec0 json_script: fix a segfault in the file free handler
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2014-05-26 15:53:29 +02:00
Felix Fietkau
d416bf6655 json_script: add json_script_run_file()
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2014-04-28 17:54:25 +02:00
Felix Fietkau
178fe974af json_script: implement json_script_eval_string
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2014-04-28 16:57:28 +02:00
Felix Fietkau
b2010c706c json_script: do not rely on global includes for other libubox header files
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-03-02 16:21:11 +01:00
Felix Fietkau
38ea521911 add json_script, a minimalistic JSON based script interpreter
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-02-28 21:50:55 +01:00