aboutsummaryrefslogtreecommitdiffstats
path: root/wsutil
AgeCommit message (Collapse)AuthorFilesLines
2019-02-02CMake: Fix DOCDIR on UnixJoão Valverde1-1/+1
User guides are installed to doc/Wireshark. Use doc/wireshark instead. Remove leftover variable CPACK_PACKAGE_NAME. Change-Id: I9a1d6bdc7d8f0b48c61e43679285d5ba83904a63 Reviewed-on: https://code.wireshark.org/review/31851 Petri-Dish: João Valverde <j@v6e.pt> Tested-by: Petri Dish Buildbot Reviewed-by: João Valverde <j@v6e.pt>
2019-02-01Fix comment.Guy Harris1-2/+1
Change-Id: I6047e0167f861214ff735b26d1965081b2b29703 Reviewed-on: https://code.wireshark.org/review/31855 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2019-02-01Have win32strerror() return interned strings.Guy Harris2-20/+19
That's what g_strerror() does, and it means that the caller doesn't need to free the string (it's kept around, and if another call to win32strerror() generates the same string, the interned string is returned). Change-Id: I564bb700fabe2629131fb1c6468494dd5f5fc9e3 Reviewed-on: https://code.wireshark.org/review/31854 Petri-Dish: Guy Harris <guy@alum.mit.edu> Tested-by: Petri Dish Buildbot Reviewed-by: Guy Harris <guy@alum.mit.edu>
2019-02-01Have win32strerror() return a g_malloc()ated UTF-8 error message.Guy Harris2-25/+60
Use FormatMessageW() to get a UTF-16-encoded Unicode error string, rather than an error string in the local code page, and then convert it from UTF-16 to UTF-8. Make it dynamically-allocated, so it's big enough and so that we are thread-safe. Make the callers free the result. Change-Id: I217aec5a644fa0176a829f181eb05561cb9d10f4 Reviewed-on: https://code.wireshark.org/review/31846 Petri-Dish: Guy Harris <guy@alum.mit.edu> Tested-by: Petri Dish Buildbot Reviewed-by: Guy Harris <guy@alum.mit.edu>
2019-01-22CMake: Set a direct rpath for librariesJoão Valverde1-0/+1
Instead of using "$ORIGIN/../lib" just use "$ORIGIN". Also be explicit in configuring the relative RPATH. We don't want to assume a default relative path, in case more targets are addded, out of caution. Change-Id: I3b7f5e8de7be8bb30aca3b433212113d876c4163 Reviewed-on: https://code.wireshark.org/review/31647 Reviewed-by: Peter Wu <peter@lekensteyn.nl>
2019-01-20json_dumper: increase JSON_DUMPER_MAX_DEPTH to 1100.Dario Lombardo1-1/+1
The new value has been chosen to make room for sharkd packet output as: proto.c:MAX_TREE_LEVELS * 2 + 10% of additional sharkd overhead. A new regression test for sharkd has been added that requires more than 15 levels. Change-Id: Ie54955c79c50c60b95c99b1a3c472888fc4842ac Reviewed-on: https://code.wireshark.org/review/31624 Petri-Dish: Peter Wu <peter@lekensteyn.nl> Tested-by: Petri Dish Buildbot Reviewed-by: Peter Wu <peter@lekensteyn.nl>
2019-01-20CMake: Replace PACKAGELIST magicJoão Valverde1-0/+8
This is more explicit and easier to read with slightly better locality while using less code. Also less awkward when the package doesn't fit the narrow package list expectations. The ws_find_package() macro doesn't include all the status messages. The choice was to rely on standard find_package() and feature_summary() output and be less verbose. Avoid polluting the CLI build interface. Per target include paths and macro definitions are preferred. Because this patch intentionally removes the global CMAKE_*_FLAGS and include_directories() usage in favor of target properties, some untested build configurations may inadvertently break because of missing ${PACKAGE}_INCLUDE_DIRS or ${PACKAGE}_DEFINITIONS. This required a manual review of dependencies that might have been incomplete. ${PACKAGE_VAR}_LINK_FLAGS seems to be unused. Changing the CMake Qt code to use more modern CMake component syntax is left as future work. Change-Id: I3ed75252189a6e05a23ed6e619088f519cd7ed78 Reviewed-on: https://code.wireshark.org/review/31496 Petri-Dish: João Valverde <j@v6e.pt> Tested-by: Petri Dish Buildbot Reviewed-by: Peter Wu <peter@lekensteyn.nl>
2019-01-08ws_pipe(.h): fix issue on doxygen documentationAlexis La Goutte1-1/+1
parameter 'argv' not found in the function declaration [-Wdocumentation] Change-Id: I68262a23e3a6f4b50d8b5e666b92f055feeaf74f Reviewed-on: https://code.wireshark.org/review/31424 Petri-Dish: Alexis La Goutte <alexis.lagoutte@gmail.com> Tested-by: Petri Dish Buildbot Reviewed-by: Michael Mann <mmann78@netscape.net>
2019-01-07str_util(.h): fix issue on doxygen documentationAlexis La Goutte1-3/+3
parameter 'string' not found in the function declaration [-Wdocumentation] Change-Id: I8c6fe47e708411e329954a682ea4da10aad348f6 Reviewed-on: https://code.wireshark.org/review/31423 Petri-Dish: Alexis La Goutte <alexis.lagoutte@gmail.com> Tested-by: Petri Dish Buildbot Reviewed-by: Gerald Combs <gerald@wireshark.org>
2019-01-04wsutil: fix code according to clang-tidy.Dario Lombardo1-3/+3
Change-Id: I7b4caed147c5813d7c9737c551b8bf1a7be48929 Reviewed-on: https://code.wireshark.org/review/31361 Petri-Dish: Dario Lombardo <lomato@gmail.com> Tested-by: Petri Dish Buildbot Reviewed-by: Peter Wu <peter@lekensteyn.nl>
2019-01-04ws_mempbrk_sse42: use same var names.Dario Lombardo1-12/+12
Found by clang-tidy. Change-Id: I2f89c6860d591c5c1563b9ca01306bb3d9e5e42c Reviewed-on: https://code.wireshark.org/review/31359 Petri-Dish: Dario Lombardo <lomato@gmail.com> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
2019-01-04ws_pipe: use same var name.Dario Lombardo1-1/+1
Found by clang-tidy. Change-Id: I0d324faf494f6b68275d6ff600304f716529778b Reviewed-on: https://code.wireshark.org/review/31358 Petri-Dish: Dario Lombardo <lomato@gmail.com> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
2019-01-04xtea: use same var name.Dario Lombardo1-8/+8
Found by clang-tidy. Change-Id: I5afce9464536cbbaf8f7f84b165d2ef56e166c2e Reviewed-on: https://code.wireshark.org/review/31357 Petri-Dish: Dario Lombardo <lomato@gmail.com> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
2019-01-04CRC6: Fixed CRC lookup table and functionsRoss2-1068/+50
* Generated code and 256-element lookup table with pycrc * Combined 2 crc6 functions which both have same poly 0x6f and lookup table * Using the example file from the bug report, $ tshark -r ~/Downloads/M1_header_crc.pcapng -V | grep "Calculated CRC" 1101 00.. = Header CRC: 0x34 [Calculated CRC 0x34] Header and Calculated CRC are now both 0x34 (correct value) * pycrc settings for generation: $ python pycrc.py --reflect-in False \ --reflect-out False \ --xor-in 0 \ --xor-out 0 \ --algorithm table-driven --width 6 \ --poly 0x2f * To manually check 3GPP protocol header CRCs, use above command with flag --check-hexstring=<HEADER HEX> Bug: 14875 Change-Id: I283f52fcae10b2f92f107df6988629d49d692428 Reviewed-on: https://code.wireshark.org/review/31356 Reviewed-by: Ross Jacobs <rossbjacobs@gmail.com> Petri-Dish: Anders Broman <a.broman58@gmail.com> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
2019-01-03Avoid definition collisions for INVALID_SOCKET.Guy Harris1-0/+2
Newer versions of libpcap define it (due to the somewhat infelicitous API for "active mode" remote capture, which returns a socket); don't define it ourselves if it's already defined. Change-Id: I620576620fd2708ebd503da696e17b472bc20472 Reviewed-on: https://code.wireshark.org/review/31344 Reviewed-by: Guy Harris <guy@alum.mit.edu>
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>
2019-01-02wsutil: fix crash due to corruption of the "small_buffers" arrayPeter Wu1-0/+3
Gracefully handle repeated calls of ws_buffer_free on the same buffer to avoid strange crashes in other new users that allocate a "small" buffer. The first call to ws_buffer_free would store data pointer in the 'small_buffers' array for reuse and set the pointer to NULL. Result: (gdb) p cfile.rec.options_buf $2 = { data = 0x0, allocated = 2048, // Oops, not modified! start = 0, first_free = 0 } All users of Buffer (including ws_buffer_free) however asssume that 'allocated' reflects the actual size of 'data'. If this is not the case (if ws_buffer_free is called again), then a data pointer (NULL!) will be stored and the next ws_buffer_init request for a "small buffer" will result in unexpected behavior (including crashes). Fix the issue by clearing the 'allocated' field as well. Add assertions to catch such issues earlier rather than crashing at random users of these buffers (such as frame_tvbuff). Bug: 15263 Change-Id: I0b491c3fccac8c6fddd43779629343d721638ca9 Reviewed-on: https://code.wireshark.org/review/31278 Petri-Dish: Peter Wu <peter@lekensteyn.nl> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
2019-01-01Happy New Year 2019!Stig Bjørlykke1-1/+1
Change-Id: Ic140aafdb32e649e88bf3f00bda3cec9404e555a Reviewed-on: https://code.wireshark.org/review/31284 Reviewed-by: Stig Bjørlykke <stig@bjorlykke.org>
2019-01-01Move some command-line-oriented routines from wsutil to ui.Guy Harris5-280/+0
cmdarg_err() is for reporting errors for command-line programs and command-line errors in GUI programs; it's not something for any of the Wireshark libraries to use. The various routines for parsing numerical command-line arguments are not for general use, they're just for use when parsing arguments. Change-Id: I100bd4a55ab8ee4497f41d9651b0c5670e6c1e7f Reviewed-on: https://code.wireshark.org/review/31281 Petri-Dish: Guy Harris <guy@alum.mit.edu> Tested-by: Petri Dish Buildbot Reviewed-by: Guy Harris <guy@alum.mit.edu>
2018-12-28Z39.50: Implementation of Z39.50 Information Retrieval protocolCraig Jackson2-2/+2
NISO Z39.50 is a protocol used by libraries and library vendors for information retrieval and catalog manipulation. It is defined using ASN.1 using BER encoding. It has an assigned TCP port of 210. This is an initial implementation. Features: - The Z39.50 standard OIDs are defined. - The bib-1 attribute set is decoded. - The bib-1 diagnostics are decoded. - Some OCTET STRINGs which are nearly always printable ASCII are special-cased. - The MARC (MAchine Readable Cataloging) format is decoded. Only the MARC21 variant is currently handled, but this is one of the most common variants. The most common tags are decoded. The MARC dissector is included in the Z39.50 dissector, but the code is structured in such away that it could be pulled out. Todo: - Add information to the Wiki about Z39.50. As part of this work, the definition of isdigit_string() was fixed to avoid const complaints. Change-Id: I29a7db53375ef8be83738a1ab98707761d878717 Reviewed-on: https://code.wireshark.org/review/31209 Petri-Dish: Anders Broman <a.broman58@gmail.com> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-12-27json_dumper: add json_dumper_value_va_list().Dario Lombardo2-4/+19
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 Lombardo2-2/+83
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 Wu2-1/+34
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-20CMake: Don't bundle our libraries at compile time.Gerald Combs1-14/+0
Setting LIBRARY_OUTPUT_DIRECTORY to Wireshark.app/Contents/Frameworks for each of our libraries ends up installing a fully versioned .dylib along with soversion and unversioned symlinks, which is more than we want and which wastes disk space when osx-app.sh dsymifies our libraries. Leave LIBRARY_OUTPUT_DIRECTORY unset and depend on osx-app.sh to copy our libraries into place. Bug: 15361 Change-Id: If0fbaa796b4be806e2aa13887e511a330fe55df5 Reviewed-on: https://code.wireshark.org/review/31139 Petri-Dish: Gerald Combs <gerald@wireshark.org> Tested-by: Petri Dish Buildbot Reviewed-by: Gerald Combs <gerald@wireshark.org>
2018-12-17wsutil: improve plugins list output format.Dario Lombardo1-1/+1
Change-Id: Id1ead7b12d437d2d4983733b34d45cad8b5c3bf2 Reviewed-on: https://code.wireshark.org/review/31067 Petri-Dish: Dario Lombardo <lomato@gmail.com> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-12-10json_dumper: add support to convert dots in underscores.Dario Lombardo2-4/+8
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-12-05Fix some spelling errors found by Lintian.Gerald Combs1-2/+2
Change-Id: If6fc3aab7ad4fc634567121f7b9541bc6f6c5766 Reviewed-on: https://code.wireshark.org/review/30926 Reviewed-by: Gerald Combs <gerald@wireshark.org> Petri-Dish: Gerald Combs <gerald@wireshark.org> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-12-04wsutil: Rename DATAFILE_DIR variableJoão Valverde2-4/+4
Rename DATAFILE_DIR to be closer to CMake and avoid mixing with the staging dir path variable of the same name. Change-Id: I7b1e02152d8bde14cca210fbfae4acbdba7d78d7 Reviewed-on: https://code.wireshark.org/review/30916 Petri-Dish: João Valverde <j@v6e.pt> Tested-by: Petri Dish Buildbot Reviewed-by: João Valverde <j@v6e.pt>
2018-12-04Clean up memory allocationJoão Valverde1-6/+7
Fixes an issue where sometimes datafile_dir is not freed before exiting. Change-Id: I2ff7d1b8ea4e20a1ce98e5e11965073eb479bb03 Reviewed-on: https://code.wireshark.org/review/30909 Petri-Dish: João Valverde <j@v6e.pt> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-12-03CMake: Simplify CMAKE_INSTALL_DATADIR usageJoão Valverde1-1/+1
Change-Id: I414aa551b8e9315a654f4da62b882e787d4f6d53 Reviewed-on: https://code.wireshark.org/review/30904 Petri-Dish: João Valverde <j@v6e.pt> Tested-by: Petri Dish Buildbot Reviewed-by: João Valverde <j@v6e.pt>
2018-11-30NSIS: Install NPcap instead of WinPcap.Gerald Combs1-1/+1
Install NPcap 0.99-r7 instead of WinPcap in the NSIS installer. Update and/or remove installer text, variables, and variable names accordingly. Change-Id: Ied36f00c2516127969894f55698e70401dfffb4f Reviewed-on: https://code.wireshark.org/review/30829 Petri-Dish: Anders Broman <a.broman58@gmail.com> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-11-29Win32: change DLL search path to accomodate extcap and NpcapPeter Wu2-34/+34
Extcap executables require libwsutil.dll from the program directory. These were loaded by setting the PATH environment variable, but this is not thread-safe (and caused sporadic tests failures as a result). Use SetDllDirectory instead, this also prevents loading DLL files from arbitrary directories in PATH. To make this work, the search logic for Npcap has to be modified to avoid relying on SetDllDirectory. This implies that Npcap cannot be used on Windows 7 anymore until KB2533623 (July 2011) is applied. Change-Id: I3fc42ff76e75ae162b6dd31103451fb8f71c09e6 Reviewed-on: https://code.wireshark.org/review/30804 Petri-Dish: Peter Wu <peter@lekensteyn.nl> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-11-29CMake: Fix some transitive link dependenciesJoão Valverde1-16/+14
libwireshark and libwiretap have their INTERFACE link dependencies changed to the required set. libwsutil keeps a default public visibility. Further work may show some unneeded link requirements. The executable dependencies are adjusted accordingly. Change-Id: I3a534f72403819cac136ae47a3d80acee76e0fb3 Reviewed-on: https://code.wireshark.org/review/30815 Reviewed-by: João Valverde <j@v6e.pt>
2018-11-26CMake: Fix runtime destination for our librariesJoão Valverde1-1/+1
Ping-Bug: 15301 Change-Id: I7d461c696ce096b7687f71277a33295eb43ff8fc Reviewed-on: https://code.wireshark.org/review/30792 Petri-Dish: João Valverde <j@v6e.pt> Tested-by: Petri Dish Buildbot Reviewed-by: João Valverde <j@v6e.pt>
2018-11-25ws_pipe_spawn_*: fix deadlock in g_spawn on Linux with threadsPeter Wu1-2/+96
The deadlock can be observed with a slow malloc implementation, e.g. ASAN_OPTIONS=fast_unwind_on_malloc=0 tshark --version (This calls extcap_run_all which uses threads and ws_pipe_spawn_sync.) Change-Id: Iff329c465c53ed177980368cd645f59222f88dd3 Reviewed-on: https://code.wireshark.org/review/30777 Petri-Dish: Peter Wu <peter@lekensteyn.nl> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-11-25Remove a stale FIXMEJoão Valverde1-0/+1
While at it prefer to use add_definitions() instead of config.h. This puts all definitions in the same place and limits the scope to the respective wsutil API. Change-Id: Idc30914220b876865e0ae47709e6f17eb9b0fc2c Reviewed-on: https://code.wireshark.org/review/30782 Petri-Dish: João Valverde <j@v6e.pt> Tested-by: Petri Dish Buildbot Reviewed-by: João Valverde <j@v6e.pt>
2018-11-24Install development headers on all platformsJoão Valverde1-5/+3
Install headers to support plugins development on Windows. Change-Id: I3161bd2f730edf62ab44fee6ce4fedbb9aee0d31 Reviewed-on: https://code.wireshark.org/review/30776 Petri-Dish: João Valverde <j@v6e.pt> Tested-by: Petri Dish Buildbot Reviewed-by: João Valverde <j@v6e.pt>
2018-11-22ws_pipe_spawn_sync: mark arguments as const where possiblePeter Wu2-4/+4
This avoids an unnecessary explicit cast. For clarity, rename the working directory argument to match g_spawn_sync. Change-Id: Idf7072cd590e686294d953f77da2a52c861a89c0 Reviewed-on: https://code.wireshark.org/review/30763 Petri-Dish: Peter Wu <peter@lekensteyn.nl> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-11-22ws_pipe_spawn_sync: debug log elapsed timePeter Wu1-0/+4
Tested with `G_MESSAGES_DEBUG=all tshark --version`. Change-Id: Iae525b9de197f012c21693a91155f931d4dcc1f7 Ping-Bug: 15295 Reviewed-on: https://code.wireshark.org/review/30759 Petri-Dish: Peter Wu <peter@lekensteyn.nl> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-11-20Allow trace of sync spawnsJaap Keuter1-9/+37
When Wireshark uses a synchronous spawn (e.g., to launch an extcap) it would be nice to be able to see what command line is constructed to launch the process, and to see what comes back. The output will go to the g_log. Change-Id: Iec6baeebc026cd80398084c9644fc916ab068e2f Reviewed-on: https://code.wireshark.org/review/30475 Petri-Dish: Dario Lombardo <lomato@gmail.com> Tested-by: Petri Dish Buildbot Reviewed-by: Peter Wu <peter@lekensteyn.nl>
2018-11-20Drop JSON-GLib completelyPeter Wu2-14/+0
JSON-GLib was added in v2.9.0rc0-201-g511c2e166a, but is no longer necessary since we have a home-grown JSON dumper (wsutil/json_dumper.h). Remove the remaining traces and additionally remove GObject from FindGLIB2.cmake since it was only added for JSON-GLib. Change-Id: If9dfd2c60cec130f98109d100bdb6618bde06ba0 Reviewed-on: https://code.wireshark.org/review/30733 Petri-Dish: Peter Wu <peter@lekensteyn.nl> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-11-20Replace JSON-GLib by custom JSON dumper libraryPeter Wu3-0/+394
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>
2018-11-20wsutil: rename some wsjson functionsPeter Wu2-9/+15
Rename wsjson_unescape_json_string to json_decode_string_inplace (inspired by the g_base64_decode_inplace name). Rename wsjson_is_valid_json to json_validate (inspired by g_unichar_validate). Ideally json_parse is inlined with its user (sharkd_session.c), but that requires exporting the jsmn_init and jsmn_parse functions... Hence the dependency on jsmn.h remains in wsjson.h. Change-Id: I7ecfe3565f15516e9115cbd7e025362df2da5416 Reviewed-on: https://code.wireshark.org/review/30731 Petri-Dish: Peter Wu <peter@lekensteyn.nl> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-11-20wsutil: fix indentation/modelines in wsjsonPeter Wu2-135/+135
The modelines says tabs, but the actual indentation is 8 spaces. Let's change it to match the standard 4 spaces in the top-level .editorconfig. Change-Id: I2b26b095f5e4f6f8d5d083d41ceaae98f9284fba Reviewed-on: https://code.wireshark.org/review/30730 Petri-Dish: Peter Wu <peter@lekensteyn.nl> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-11-01ws_pipe_close(): also close the handle after terminating processPascal Quantin1-2/+1
Change-Id: Ie19eba9706e2af1a58a6946e8af68ab90c0c8a7d Reviewed-on: https://code.wireshark.org/review/30456 Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
2018-11-01wsutil: introduce ws_pipe_close() helper and use it to terminate mmdbresolvePascal Quantin2-0/+18
We were not calling TerminateProcess() to stop mmdbresolve.Exe process on Windows. Bug: 15248 Change-Id: Ic90cf438a8003a6fefb023b7056984681ce09b46 Reviewed-on: https://code.wireshark.org/review/30449 Petri-Dish: Pascal Quantin <pascal.quantin@gmail.com> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-11-01Move condition logic to dumpcap.cGerald Combs2-0/+20
Move the condition logic from capture_stop_conditions.c to dumpcap.c. Remove capture_stop_conditions.[ch] and conditions.[ch]. Switch duration values to doubles. Change-Id: Ifa74fb13ec8fc923b0721597a6cf071d72069ea0 Reviewed-on: https://code.wireshark.org/review/30440 Reviewed-by: Gerald Combs <gerald@wireshark.org> Petri-Dish: Gerald Combs <gerald@wireshark.org> Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-10-19Use ws_basetostru32(), rather than strtoul(), when parsing ranges.Guy Harris2-2/+24
Make ws_basetostru32(), and the other ws_baseto... routines, public, and use ws_basetostru32() when parsing ranges, to detect additional errors such as negative values. Addresses part of https://ask.wireshark.org/question/5538/preference-range/. Change-Id: I00fac97a198a237b01b5cd9406ea32c220f80972 Reviewed-on: https://code.wireshark.org/review/30266 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2018-10-14Note that you have to be careful reading messages from a pipe.Guy Harris1-0/+15
Change-Id: I354e0633b8bd1da3d95fcb770fb9d5a0e4ee5880 Reviewed-on: https://code.wireshark.org/review/30212 Reviewed-by: Guy Harris <guy@alum.mit.edu>