aboutsummaryrefslogtreecommitdiffstats
path: root/wsutil/json_dumper.c
AgeCommit message (Collapse)AuthorFilesLines
2019-03-22json_dumper: flush dumper before printing an error.Dario Lombardo1-0/+1
This helps the developer in the debug phases. Change-Id: I85558334b5d618219a48a6c00129cd36a6ab0b10 Reviewed-on: https://code.wireshark.org/review/32531 Petri-Dish: Dario Lombardo <lomato@gmail.com> Reviewed-by: Peter Wu <peter@lekensteyn.nl> Tested-by: Petri Dish Buildbot Reviewed-by: Dario Lombardo <lomato@gmail.com>
2019-02-12json_dumper: escape forward slash in some stringsPeter Wu1-0/+3
If the JSON output is written in a script tag for a HTML page, be sure to not to break it. Change-Id: I1b9ba6a39faf266e8a7bf9befa2899978beb130c Reviewed-on: https://code.wireshark.org/review/31953 Petri-Dish: Peter Wu <peter@lekensteyn.nl> Tested-by: Petri Dish Buildbot Reviewed-by: Dario Lombardo <lomato@gmail.com> Reviewed-by: Anders Broman <a.broman58@gmail.com>
2019-02-11json_dumper: add json_dumper_value_doublePeter Wu1-0/+20
Add locale-independent version that replaces json_dumper_value_anyf for floating-point numbers. NaN and -/+Infinity are mapped to null. Change-Id: I8e7856de480b7bcafe77ddd015239e1257768ced Reviewed-on: https://code.wireshark.org/review/31948 Reviewed-by: Peter Wu <peter@lekensteyn.nl> Petri-Dish: Peter Wu <peter@lekensteyn.nl> Tested-by: Petri Dish Buildbot Reviewed-by: Jakub Zawadzki <jbwzawadzki@gmail.com> Reviewed-by: Anders Broman <a.broman58@gmail.com>
2019-01-03json_dumper: make json_dumper_bad fatal.Dario Lombardo1-1/+1
A call to this function means a programming error. g_error makes it fatal and terminates the program, making the debug easier. Change-Id: I5c9e82507482733b4d450ed6c3a9fc17fb0fcdca Reviewed-on: https://code.wireshark.org/review/31310 Petri-Dish: Peter Wu <peter@lekensteyn.nl> Petri-Dish: Dario Lombardo <lomato@gmail.com> Tested-by: Petri Dish Buildbot Reviewed-by: Peter Wu <peter@lekensteyn.nl>
2018-12-27json_dumper: add json_dumper_value_va_list().Dario Lombardo1-4/+11
Change-Id: I8effb701b505e5ce0c06be42ab524c458e1839ce Reviewed-on: https://code.wireshark.org/review/31207 Reviewed-by: Peter Wu <peter@lekensteyn.nl> Petri-Dish: Peter Wu <peter@lekensteyn.nl> Tested-by: Petri Dish Buildbot Reviewed-by: Dario Lombardo <lomato@gmail.com>
2018-12-23json_dumper: add base64 routines.Dario Lombardo1-2/+68
Change-Id: Iab9a201fe951e5557501f4e675ab74ecd9dbb930 Reviewed-on: https://code.wireshark.org/review/31034 Petri-Dish: Dario Lombardo <lomato@gmail.com> Tested-by: Petri Dish Buildbot Reviewed-by: Peter Wu <peter@lekensteyn.nl>
2018-12-22json_dumper: add debugging print as corruption checkPeter Wu1-0/+33
Print warnings to help with debugging. Add Jakub (author of json_puts_string). Change-Id: I8bf039afc21357e97accb2a9abf9378735af12eb Reviewed-on: https://code.wireshark.org/review/31041 Petri-Dish: Peter Wu <peter@lekensteyn.nl> Tested-by: Petri Dish Buildbot Reviewed-by: Dario Lombardo <lomato@gmail.com> Reviewed-by: Peter Wu <peter@lekensteyn.nl>
2018-12-10json_dumper: add support to convert dots in underscores.Dario Lombardo1-4/+7
This is needed for ek json compatibility. Change-Id: I75c74a1dc7996f3f4c17071508655ae6e3c6b94c Reviewed-on: https://code.wireshark.org/review/30993 Petri-Dish: Dario Lombardo <lomato@gmail.com> Tested-by: Petri Dish Buildbot Reviewed-by: Peter Wu <peter@lekensteyn.nl>
2018-12-09json_dumper: support 'null' json object.Dario Lombardo1-0/+5
Allow the function json_puts_string() to be called with the NULL argument that translates to 'null' json object. Change-Id: I3d2aafad446962d3342ab30b9d509f054d393c64 Reviewed-on: https://code.wireshark.org/review/30978 Petri-Dish: Dario Lombardo <lomato@gmail.com> Tested-by: Petri Dish Buildbot Reviewed-by: Peter Wu <peter@lekensteyn.nl>
2018-11-20Replace JSON-GLib by custom JSON dumper libraryPeter Wu1-0/+285
The (optional) JSON-GLib library adds dependencies on GObject, GIO. For statically linked oss-fuzz builds it also adds libffi and more. To avoid these dependencies, replace JSON-GLib by some custom code. This allows `tshark -G elastic-mapping` to be enabled by default without extra deps. API design goals of the new JSON dumper library: - Small interface without a lot of abstraction. - Avoid memory allocations if possible (currently none, but maybe json_puts_string will be replaced to improve UTF-8 support). - Do not implement parsing, this is currently handled by jsmn. Methods to open/close array/objects and to set members are inspired by the JsonGlib interface. The interfaces to write values is inspired by the sharkd code (json_puts_string is also borrowed from that). The only observed differences in the tshark output: - JSON-GLib ignores duplicates, json_dumper does not and may produce duplicates and currently print two "ip.opt.sec_prot_auth_unassigned". - JSON-GLib adds a space before a colon (unimportant formatting detail). - (Not observed, but UTF-8 strings will be wrong like bug 14948.) A test was added to catch changes in the tshark output. I also fuzzed json_dumper with libFuzzer + UBSAN/ASAN and fixed an off-by-one error. Change-Id: I0c85b18777b04d1e0f613a3d59935ec59be87ff4 Link: https://www.wireshark.org/lists/wireshark-dev/201811/msg00052.html Reviewed-on: https://code.wireshark.org/review/30732 Petri-Dish: Peter Wu <peter@lekensteyn.nl> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>