Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.openwrt.org/project/libubox.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/jshn.c
AgeCommit message (Collapse)Author
2020-01-20jshn: prefer snprintf usagePetr Štetiar
Better safe than sorry. Reviewed-by: Jo-Philipp Wich <jo@mein.io> Signed-off-by: Petr Štetiar <ynezz@true.cz>
2019-11-24jshn: fix missing usage for -p and -o argumentsPetr Štetiar
Add missing usage hints for -p and -o arguments. Fixes: e16fa068a573 ("jshn: add support for namespaces") Fixes: eb30a03048f8 ("libubox, jshn: add option to write output to a file") Signed-off-by: Petr Štetiar <ynezz@true.cz>
2019-11-24jshn: fix off by one in jshn_parse_filePetr Štetiar
Fixes following error: Invalid read of size 1 at 0x4C32D04: strlen by 0x5043367: json_tokener_parse_ex by 0x5045316: json_tokener_parse_verbose by 0x504537D: json_tokener_parse by 0x401AB1: jshn_parse (jshn.c:179) by 0x40190D: jshn_parse_file (jshn.c:370) by 0x40190D: main (jshn.c:434) Address 0x5848c4c is 0 bytes after a block of size 1,036 alloc'd at 0x4C2FB0F: malloc by 0x4018E2: jshn_parse_file (jshn.c:357) by 0x4018E2: main (jshn.c:434) Signed-off-by: Petr Štetiar <ynezz@true.cz>
2019-11-24jshn: jshn_parse: fix leaks of memory pointed to by 'obj'Petr Štetiar
Fixes following leaks of memory: 352 (72 direct, 280 indirect) bytes in 1 blocks are definitely lost in loss record 3 of 3 at 0x4C31B25: calloc by 0x5042E1F: json_object_new_array by 0x5044B02: json_tokener_parse_ex by 0x5045316: json_tokener_parse_verbose by 0x504537D: json_tokener_parse by 0x401AA9: jshn_parse (jshn.c:179) by 0x401977: main (jshn.c:378) 752 (72 direct, 680 indirect) bytes in 1 blocks are definitely lost in loss record 6 of 6 at 0x4C31B25: calloc by 0x50424CF: json_object_new_object by 0x5044B38: json_tokener_parse_ex by 0x5045316: json_tokener_parse_verbose by 0x504537D: json_tokener_parse by 0x401AA9: jshn_parse (jshn.c:179) by 0x401977: main (jshn.c:380) Signed-off-by: Petr Štetiar <ynezz@true.cz>
2019-11-24jshn: main: fix leak of memory pointed to by 'vars'Petr Štetiar
Fixes following leak of memory: 6,016 bytes in 1 blocks are possibly lost in loss record 1 of 1 at 0x4C31B25: calloc by 0x1098F8: main (jshn.c:353) Signed-off-by: Petr Štetiar <ynezz@true.cz>
2019-11-24jshn: refactor main into smaller piecesPetr Štetiar
Turn longer switch cases into separate functions in order to make it easier to follow. Don't return from the cases as it makes future cleaning up harder. Signed-off-by: Petr Štetiar <ynezz@true.cz>
2019-10-21libubox, jshn: add option to write output to a fileRoman Yeryomin
This would allow board_config_flush to run one command instead of two and would be faster and safer than redirecting output and moving a file between filesystems. Originally discussed here: http://lists.openwrt.org/pipermail/openwrt-devel/2017-December/010127.html Signed-off-by: Roman Yeryomin <roman@advem.lv>
2018-04-07jshn: fix format string for int64 typeFelix Fietkau
Signed-off-by: Felix Fietkau <nbd@nbd.name>
2018-01-22jshn: add functionality to read big JSONChristian Beier
The existing read functionality feeds the complete JSON to jshn as a cmdline argument, leading to `-ash: jshn: Argument list too long` errors for JSONs bigger than ca. 100KB. This commit adds the ability to read the JSON directly from a file if wanted, removing this shell-imposed size limit. Tested on x86-64 and ar71xx. An mmap()-based solution was also evaluated, but found to make no performance difference on either platform. Signed-off-by: Christian Beier <dontmind@freeshell.org>
2018-01-07jshn: properly support JSON "null" typeJo-Philipp Wich
Instead of abort parsing, properly deal with "null" values by implementing support for reading and formatting such values. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2017-11-06jshn: read and write 64-bit integersChristian Beier
This allows for reading in and writing out bigger JSON Numbers. Following test script (that fails to print correct values _without_ this commit) verifies the functionality (tested on x86-64 as well as on ar71xx): ---snip--- # assumes you built jshn and sourced jshn.sh echo testing reading-in JSON SHELL_BIGNUM=12147483647 json_init json_load "{ \"bignum\": $SHELL_BIGNUM }" json_get_var BIGNUM bignum echo jshn bignum: $BIGNUM echo shll bignum: $SHELL_BIGNUM echo testing writing-out JSON json_init json_add_int bigint $SHELL_BIGNUM json_dump --snap--- Signed-off-by: Christian Beier <dontmind@freeshell.org>
2016-06-26Fix various memory management issuesMatthias Schiffer
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-03-05jshn: use an avl tree for env variables to speed up processing of bigger ↵Felix Fietkau
json files Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2014-12-11jshn: add error handling and fix memory leak in jshn_format().Yousong Zhou
Though currently jshn is more a one-shot data transformation tool and won't leak much memory in its lifetime, people may use it as example code, so do it right. Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
2014-11-23jshn: shorten JSON_VAR to J_VFelix Fietkau
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2014-11-23jshn: shorten variable names to speed up processingFelix Fietkau
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2014-09-23avoid using the deprecated is_error() function from json-cFelix Fietkau
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2014-08-04jshn: pretty print indented output with jshn -i -wJohn Crispin
Signed-off-by: John Crispin <blogic@openwrt.org>
2013-03-17jshn: add support for the double datatypeFelix Fietkau
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2013-03-05add pkgconfig support for json-cThomas Gstädtner
this includes a fallback for legacy support
2013-01-13jshn: add copyright infoFelix Fietkau
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2012-12-16jshn: add support for namespacesFelix Fietkau
Can be used to fix variable namespace clashes in library code using jshn Signed-off-by: Felix Fietkau <nbd@openwrt.org>
2011-09-11jshn: support using characters in elements that do not conform to shell ↵Felix Fietkau
variable restrictions
2011-08-12change the include path for list.h in jshn.cFelix Fietkau
2011-05-31jshn: add an option for printing the json data without a terminating newlineFelix Fietkau
2011-05-24add jshnFelix Fietkau