aboutsummaryrefslogtreecommitdiffstats
path: root/wsutil
AgeCommit message (Collapse)AuthorFilesLines
2021-03-16Move even more headers outside extern "C".Guy Harris6-23/+32
If a header declares a function, or anything else requiring the extern "C" decoration, have it wrap the declaration itself; don't rely on the header itself being included inside extern "C".
2021-03-15Add more error-reporting routines that call through a function pointer.Guy Harris2-27/+123
Have routines to report capture-file errors, using libwireshark error codes and strings, that call through a pointer, so they can pop up dialogs in GUI apps, print a message to the standard error on command-line apps, and possibly do something different on server programs. Have init_report_message() take a pointer to structure containing those function pointers, rather than the function pointers themselves, as arguments. Make other API changes to make that work.
2021-03-05Replace g_assert(0) with g_assert_not_reached()João Valverde1-1/+1
2021-03-04peektagged: guess the PHY for 11b/11g/11a.Guy Harris1-1/+42
FOr 11b and 11g, also set the metadata to provide the "short preamble" indication. Add some macros to wsutil/802_11-utils.h to help there, as I threatened to do in the previous commit. :-)
2021-03-04wsutil: rename frequency-utils.[ch] to 802_11-utils.[ch].Guy Harris3-14/+16
It's 802.11-specific, and may include non-frequency/channel-related items in the future.
2021-03-01CMake: Use CheckAPI's abort/termoutput with dissectors onlyJoão Valverde1-1/+0
I believe this was the original intention, to use these API restricitons with dissectors only (not that I necessarily agree with that policy either), and through copy-paste and lack of clear guidelines it spread to other parts of the build. Rename the checkAPI groups to make it very clear that this is dissector-only. This doesn't mean, of course, that good programming practices shouldn't be followed everywhere. In particular assertions need to be used properly. Don't use them to catch runtime errors or validate input data. This commit will be followed by another removing the various ugly hacks people have been using to get around the checkAPI hammer.
2021-02-28Remove and replace obsolete ws_snprintf() definitionJoão Valverde1-56/+0
Since fe94133f0d06935bb5f2afe21f59bbb078d3d9d3 ws_snprintf() and ws_vsnprintf() don't actually do anything anymore. The return value of ws_[v]snprintf was discarded before, now it too conforms to C99.
2021-02-10Moving glib.h out of extern CMichal Ruprich2-4/+4
2021-02-06Avoid exposing HAVE_PLUGINS in the public APIJoão Valverde3-10/+16
Instead *_register_plugin() is turned into a noop (with a warning). The test suit is failing with ENABLE_PLUGINS=Off (it was already failing before and this patch didn't affect that). Closes #17202.
2021-01-30Don't include config.h in system headersJoão Valverde1-2/+0
Config.h must not be installed so configuration must be performed by client code. Fixes #17190.
2021-01-14nstime: Remove an unneeded check.Gerald Combs1-7/+0
2021-01-11editcap: add support for epoch timestamps in `-A` and `-B` optionsChema Gonzalez2-0/+83
Inspired in https://gitlab.com/wireshark/wireshark/-/merge_requests/1618. Tested: Timestamps on file used for comparison: ``` $ tshark -r test/captures/snakeoil-dtls.pcap -T fields -e frame.time_epoch 1150121069.248818000 1150121069.249193000 1150121069.251152000 1150121069.251384000 1150121069.293686000 1150121069.319315000 1150121075.230753000 1150121105.510885000 1150121105.510934000 ``` Before: ``` $ ./build/run/editcap -B 1150121069.3 test/captures/snakeoil-dtls.pcap - editcap: "1150121069.3" isn't a valid date and time $ ./build/run/editcap -A 1150121069.3 test/captures/snakeoil-dtls.pcap - editcap: "1150121069.3" isn't a valid date and time $ ./build/run/editcap -A 1150121069 test/captures/snakeoil-dtls.pcap - editcap: "1150121069" isn't a valid date and time $ ./build/run/editcap -B 1150121069 test/captures/snakeoil-dtls.pcap - editcap: "1150121069" isn't a valid date and time ``` After: ``` $ ./build/run/editcap -A 1150121069.3 test/captures/snakeoil-dtls.pcap - | tshark -r - -T fields -e frame.time_epoch 1150121069.319315000 1150121075.230753000 1150121105.510885000 1150121105.510934000 $ ./build/run/editcap -A 1150121069 test/captures/snakeoil-dtls.pcap - | tshark -r - -T fields -e frame.time_epoch 1150121069.248818000 1150121069.249193000 1150121069.251152000 1150121069.251384000 1150121069.293686000 1150121069.319315000 1150121075.230753000 1150121105.510885000 1150121105.510934000 $ ./build/run/editcap -B 1150121069.3 test/captures/snakeoil-dtls.pcap - | tshark -r - -T fields -e frame.time_epoch 1150121069.248818000 1150121069.249193000 1150121069.251152000 1150121069.251384000 1150121069.293686000 $ ./build/run/editcap -B 1150121069 test/captures/snakeoil-dtls.pcap - | tshark -r - -T fields -e frame.time_epoch ```
2021-01-08Add iso8601_to_nstime() for editcap and nettraceDavid Perry4-1/+247
This adds a function to parse a string date-time in ISO 8601 format into a `nstime_t` structure. It's based on code from epan/tvbuff.c and wiretap/nettrace_3gpp_32_423.c and meant to eventually replace both. (Currently only replaces the latter.) Since most of Wireshark expects ISO 8601 date-times to fit a fairly strict pattern, iso8601_to_nstime() currently rejects date-times without separators between the components, even though ISO 8601 actually permits this. This could be revisited later. Also uses iso8601_to_nstime in editcap to parse the -A/-B options, thus allowing the user to specify a time zone if desired. (See #17110)
2021-01-01Happy New Year 2021Stig Bjørlykke1-1/+1
2020-12-22Detect and replace bad allocation patternsMoshe Kaplan2-2/+2
Adds a pre-commit hook for detecting and replacing occurrences of `g_malloc()` and `wmem_alloc()` with `g_new()` and `wmem_new()`, to improve the readability of Wireshark's code, and occurrences of `g_malloc(sizeof(struct myobj) * foo)` with `g_new(struct myobj, foo)` to prevent integer overflows Also fixes all existing occurrences across the codebase.
2020-10-19CMake: Replace checking with a status messageJoão Valverde1-2/+5
2020-10-11Fix many spelling errorsРоман Донченко8-8/+8
2020-09-16Update our issue tracker URL in some places.Gerald Combs1-5/+5
Replace bugs.wireshark.org links with their equivalent gitlab.com/wireshark/wireshark/issues links in the AsciiDoctor buglink macro and the please_report_bug function. Update the bug URLs in comments in the tools and test directories.
2020-09-07Yet more spelling fixes.Martin Mathieson1-1/+1
Includes small updates to the script and wireshark dictionary. Probably the last spelling fixes from me for a while.
2020-09-05Tools: Clean up checkAPI and add ui/qt.Gerald Combs1-1/+1
Remove the --check-addtext and --build flags. They were used for checkAddTextCalls, which was removed in e2735ecfdd. Add the sources in ui/qt except for qcustomplot.{cpp,h}. Fix issues in main.cpp, rtp_audio_stream.cpp, and wireshark_zip_helper.cpp. Rename "index"es in packet-usb-hid.c.
2020-08-11wsutil: define HAVE_LIBGCRYPT_AEAD in wsutil/wsgcrypt.h.Guy Harris1-0/+19
It's used in a number of source files; don't force each of them to test GCRYPT_VERSION_NUMBER independently. Make sure every file that uses HAVE_LIBGCRYPT_AEAD includes wsutil/wsgcrypt.h. Also do some other definitions that are based on the libgcrypt version there as well. This requires that the Qt UI code be given the include directory for libgcrypt, as the follow stream code includes epan/dissectors/packet-quic.h, which includes wsutil/wsgcrypt.h to get HAVE_LIBGCRYPT_AEAD defined, and wsutil/wsgcrypt.h includes <gcrypt.h>. Change-Id: I9cb50f411f5b2b6b9e28a38bfd901f4a66d9cc8f Reviewed-on: https://code.wireshark.org/review/38116 Petri-Dish: Guy Harris <gharris@sonic.net> Tested-by: Petri Dish Buildbot Reviewed-by: Guy Harris <gharris@sonic.net>
2020-05-03Some more issues identified by PVS-Studio.Martin Mathieson1-4/+6
/opt/SourceCode/wireshark/epan/dissectors/packet-osc.c 367 err V562 It's odd to compare 0 or 1 with a value of 0. /opt/SourceCode/wireshark/epan/dissectors/packet-rpc.c 960 note V576 Incorrect format. Consider checking the eighth actual argument of the 'proto_tree_add_subtree_format' function. The SIGNED integer type argument is expected. /opt/SourceCode/wireshark/epan/dissectors/packet-rpc.c 980 note V576 Incorrect format. Consider checking the third actual argument of the 'proto_item_append_text' function. The SIGNED integer type argument is expected. /opt/SourceCode/wireshark/epan/dissectors/packet-rpc.c 2473 note V576 Incorrect format. Consider checking the fourth actual argument of the 'col_prepend_fstr' function. The SIGNED integer type argument is expected. /opt/SourceCode/wireshark/epan/dissectors/packet-rpc.c 2482 note V576 Incorrect format. Consider checking the fourth actual argument of the 'col_append_fstr' function. The SIGNED integer type argument is expected. /opt/SourceCode/wireshark/epan/dissectors/packet-rpc.c 2633 note V576 Incorrect format. Consider checking the fourth actual argument of the 'col_append_fstr' function. The SIGNED integer type argument is expected. /opt/SourceCode/wireshark/epan/dissectors/packet-rpc.c 2650 note V576 Incorrect format. Consider checking the fourth actual argument of the 'col_prepend_fstr' function. The SIGNED integer type argument is expected. /opt/SourceCode/wireshark/epan/dissectors/packet-stun.c 565 warn V1051 Consider checking for misprints. It's possible that the 'reported_length' should be checked here. /opt/SourceCode/wireshark/epan/dissectors/packet-umts_fp.c 4126 warn V1051 Consider checking for misprints. It's possible that the 'reported_length' should be checked here. /opt/SourceCode/wireshark/epan/dissectors/packet-umts_fp.c 4942 warn V1051 Consider checking for misprints. It's possible that the 'reported_length' should be checked here. /opt/SourceCode/wireshark/ui/voip_calls.c 1444 err V773 The 'comment' pointer was assigned values twice without releasing the memory. A memory leak is possible. /opt/SourceCode/wireshark/wsutil/filesystem.c 1531 err V773 The function was exited without releasing the 'files' pointer. A memory leak is possible. /opt/SourceCode/wireshark/wsutil/filesystem.c 1717 err V773 The function was exited without releasing the 'files' pointer. A memory leak is possible. Bug: 16335 Change-Id: I8df3ba6d070823dcb43c4152d9156358f701e8dc Reviewed-on: https://code.wireshark.org/review/37069 Petri-Dish: Guy Harris <gharris@sonic.net> Tested-by: Petri Dish Buildbot Reviewed-by: Guy Harris <gharris@sonic.net>
2020-03-25nstime: make declaration arg order match definitionMartin Mathieson1-1/+1
wsutil/nstime.c:116: warning: Function 'nstime_sum' argument order different: declaration 'sum, b, a' definition 'sum, a, b' Most likely copy/paste error from nstime_delta() above where that order makes sense. Change-Id: Icea52b21781ebc09b2b80acdb34d61a28eb1e498 Reviewed-on: https://code.wireshark.org/review/36562 Petri-Dish: Martin Mathieson <martin.r.mathieson@googlemail.com> Tested-by: Petri Dish Buildbot Reviewed-by: Martin Mathieson <martin.r.mathieson@googlemail.com>
2020-03-23tempfile(.h): fix -WdocumentationAlexis La Goutte1-1/+1
tempfile.h:33:11: warning: parameter 'sfx' is already documented [-Wdocumentation] Change-Id: I026ea52c484fb75a69f15b02e6eee5ce599da0e7 Reviewed-on: https://code.wireshark.org/review/36541 Reviewed-by: Dario Lombardo <lomato@gmail.com> Petri-Dish: Dario Lombardo <lomato@gmail.com> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
2020-02-25Add ws_strtoi() and ws_strtoui() routines and use them.Guy Harris2-0/+88
Those fetch gint and guint values, respectively, rather than values with specified sizes in bits. This should squelch Coverity CID 1457357. Change-Id: Ia8f100bd3fe90c266e24a4346f80b2667c653b93 Reviewed-on: https://code.wireshark.org/review/36177 Petri-Dish: Guy Harris <guy@alum.mit.edu> Tested-by: Petri Dish Buildbot Reviewed-by: Guy Harris <guy@alum.mit.edu>
2020-02-15wsutil: Strip the processor brand string.Gerald Combs1-1/+1
The processor brand string returned by CPUID is left-padded in some cases. For example, adding g_warning("==>%s<==\n", CPUBrandString); to get_cpu_info() on a test machine here returns ** (tshark.exe:3808): WARNING **: ==> Intel(R) Core(TM) i5-3320M CPU @ 2.60GHz<== Make sure it's stripped before we add it to our version information. Change-Id: Idf9f9574477043a5e7fe4ff1ecb7890d6da90e0a Reviewed-on: https://code.wireshark.org/review/36108 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>
2020-01-21Put various epoch time deltas into wsutil/epochs.h.Guy Harris4-28/+66
There are some deltas between the UN*X epoch and other epochs that are used in a number of places; put them into a header. Change-Id: Ia2d9d69b9d91352d730d97d9e4897518635b4861 Reviewed-on: https://code.wireshark.org/review/35895 Petri-Dish: Guy Harris <guy@alum.mit.edu> Tested-by: Petri Dish Buildbot Reviewed-by: Guy Harris <guy@alum.mit.edu>
2020-01-06wsutil: Replace disallowed filename characters to '-'Stig Bjørlykke1-1/+18
Revert the removal of replacing disallowed filename characters in create_tempfile() to allow this characters in extcap interface names. This is a regression from g2925fb08. Change-Id: I833d1d19080c9c688dcaf076a840f55ef31e457d Reviewed-on: https://code.wireshark.org/review/35669 Reviewed-by: Stig Bjørlykke <stig@bjorlykke.org> Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org> Tested-by: Petri Dish Buildbot Reviewed-by: Guy Harris <guy@alum.mit.edu>
2020-01-05Try this - it might be clearer.Guy Harris1-1/+1
It doesn't contain the text "please do not report it", so nobody will think it's a warning not to report the problem, it just says "don't call it a crash". Change-Id: I9ce71e6a1cc37446a08e44da64c8411166844f75 Reviewed-on: https://code.wireshark.org/review/35649 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2020-01-05Rewrite the "please submit" message a bit.Guy Harris1-2/+2
Say "as a bug" upfront, and clarify that "please do not report it as such" doesn't mean "please do not report this at all" (even though we say "please report this" earlier), it means "please do not report this as being a crash". Change-Id: I2656c4c13e90fcf41d00a4b6ab3c2f2998f55fd6 Reviewed-on: https://code.wireshark.org/review/35647 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2020-01-01Happy New Year 2020Stig Bjørlykke1-1/+1
Change-Id: Ic569e499d40def9397203510a121ff17a495ba9a Reviewed-on: https://code.wireshark.org/review/35616 Reviewed-by: Stig Bjørlykke <stig@bjorlykke.org>
2019-12-30codecs API: Added description of API usageJirka Novak1-4/+64
Added API description clarifies when bytes/samples are used. New variable names proposed and all existing codecs are adapted to it. Change is just renaming... Change-Id: I75dba64a49eb3f4369ec7160cb793dda4b44c810 Reviewed-on: https://code.wireshark.org/review/35576 Reviewed-by: Michael Mann <mmann78@netscape.net> Petri-Dish: Michael Mann <mmann78@netscape.net> Tested-by: Petri Dish Buildbot Reviewed-by: Pascal Quantin <pascal@wireshark.org>
2019-12-20Use g_file_open_tmp within create_tempfileMichael Mann2-165/+16
Much better to use a known library than create it ourselves. Also remove get_tempfile_path as it's not used. Bug: 15992 Change-Id: I17b9bd879e8bdb540f79db83c6c138f8ee724764 Reviewed-on: https://code.wireshark.org/review/34420 Reviewed-by: Tomasz Moń <desowin@gmail.com> Petri-Dish: Tomasz Moń <desowin@gmail.com> Tested-by: Petri Dish Buildbot Reviewed-by: Roland Knall <rknall@gmail.com>
2019-12-02Add format_size_wmemMichael Mann2-15/+25
It's a "wmem version" of format_size (from wsutil/str_util.h). Also improved the flexibility in formatting of format_size() to handle future needs of format_size_wmem Ping-Bug: 15360 Change-Id: Id9977bbd7ec29375bbac955f685d46e75b0cef2c Reviewed-on: https://code.wireshark.org/review/31233 Petri-Dish: Michael Mann <mmann78@netscape.net> Tested-by: Petri Dish Buildbot Reviewed-by: Peter Wu <peter@lekensteyn.nl> Reviewed-by: Anders Broman <a.broman58@gmail.com>
2019-11-12wsutil: add netinet/in.h to socket.h.Dario Lombardo1-0/+4
Fix compilation under FreeBSD x86. Change-Id: Ifad9b21eb299e07e5a91424705e70b18e394eafc Reviewed-on: https://code.wireshark.org/review/35061 Petri-Dish: Dario Lombardo <lomato@gmail.com> Tested-by: Petri Dish Buildbot Reviewed-by: Guy Harris <guy@alum.mit.edu>
2019-11-11Include <string.h>.Guy Harris1-0/+1
strchr() is declared in <string.h>, and we now use strchr(), so we must include <string.h>. Change-Id: Ie80763c10c4ad1ef85d4a83d8eacc3ea236bea56 Reviewed-on: https://code.wireshark.org/review/35052 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2019-11-11dumpcap: Add support for TCP@IPv6 socket capturesJoão Valverde2-0/+111
Bug: 15820 Change-Id: Id32f376190c115b0808ba72e5b63e019e2a70274 Reviewed-on: https://code.wireshark.org/review/35030 Petri-Dish: João Valverde <j@v6e.pt> Tested-by: Petri Dish Buildbot Reviewed-by: João Valverde <j@v6e.pt>
2019-10-30Fix the temporary file string buffer expansion.Guy Harris1-2/+4
The buffer needs to be big enough to include the trailing '\0', so we need to compare the buffer's length against strlen(name) + 1, not against strlen(name). Bug: 15751 Change-Id: I75ae65f8c818284834d761d9dd911d029cfca3b1 Reviewed-on: https://code.wireshark.org/review/34892 Petri-Dish: Guy Harris <guy@alum.mit.edu> Tested-by: Petri Dish Buildbot Reviewed-by: Guy Harris <guy@alum.mit.edu>
2019-10-10Revert "CMake: Don't install HTML manuals twice"João Valverde3-41/+6
This reverts commit f1285fcf061669702ca1accd7b2c50ebc8198993. NSIS package is broken with this commit. Change-Id: Ief22a308edad188fa2d5fab79355f19493359fa6 Reviewed-on: https://code.wireshark.org/review/34758 Petri-Dish: João Valverde <j@v6e.pt> Tested-by: Petri Dish Buildbot Reviewed-by: João Valverde <j@v6e.pt>
2019-10-09CMake: Don't install HTML manuals twiceJoão Valverde3-6/+41
HTML docs are installed to both $docdir and $pkgdatadir. Fix that to install to $docdir only. Change-Id: I115158585b6df9170d9a01249adbc8548df91f14 Reviewed-on: https://code.wireshark.org/review/34640 Petri-Dish: João Valverde <j@v6e.pt> Tested-by: Petri Dish Buildbot Reviewed-by: João Valverde <j@v6e.pt>
2019-10-03Win32: Fix a return value check.Gerald Combs1-1/+1
CreateNamedPipe returns INVALID_HANDLE_VALUE on failure. Change-Id: I79ad5144e084520db8197b69c4ad34431d183009 Reviewed-on: https://code.wireshark.org/review/34704 Reviewed-by: Gerald Combs <gerald@wireshark.org> Petri-Dish: Gerald Combs <gerald@wireshark.org> Tested-by: Petri Dish Buildbot Reviewed-by: Guy Harris <guy@alum.mit.edu>
2019-09-25Fix opening manual from staging directoryJoão Valverde1-2/+0
Change-Id: I6ac18a0379c4366c12dfb7dc00970e68451563a1 Reviewed-on: https://code.wireshark.org/review/34605 Petri-Dish: João Valverde <j@v6e.pt> Tested-by: Petri Dish Buildbot Reviewed-by: Jaap Keuter <jaap.keuter@xs4all.nl>
2019-09-24wsutil: Use file descriptor in file_needs_reopen()Tomasz Moń2-5/+4
There's no extra benefit in having FILE pointer (over file descriptor) passed to file_needs_reopen(). Change-Id: Id49eb2f02b776c2f1ccd9d67fedd7eac38432f52 Reviewed-on: https://code.wireshark.org/review/34600 Reviewed-by: Craig Jackson <cejackson51@gmail.com> Petri-Dish: Anders Broman <a.broman58@gmail.com> Tested-by: Petri Dish Buildbot Reviewed-by: Guy Harris <guy@alum.mit.edu>
2019-09-22Win32: Do not reload TLS keylog file on each packetTomasz Moń2-0/+71
On Windows, fstat() and stat() sets st_dev to different value depending on whether it was called with file handle or file path. If file handle was used, the st_dev is simply the file handle casted to unsigned. If file path was used, then st_dev corresponds to drive letter (A=0, B=1, C=2, ...). Compare the files using the file index information retrieved by GetFileInformationByHandle(). When compiled in configuration that supports FILE_ID_INFO, the code first tries to obtain 128-bit FILE_ID_INFO and if that fails, fallback to GetFileInformationByHandle(). Bug: 16059 Change-Id: I5f8d8d8127337891ef9907c291e550b1d17aabbb Reviewed-on: https://code.wireshark.org/review/34573 Reviewed-by: Peter Wu <peter@lekensteyn.nl> Petri-Dish: Peter Wu <peter@lekensteyn.nl> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
2019-09-21MSVC: Warn about unused formal parametersTomasz Moń3-4/+14
Provide _U_ macro definition for Visual Studio. Change the way _U_ macro is ifdefed for some targets to allow Visual Studio to recognize it. Ping-Bug: 15832 Change-Id: Ic7ce145cbe9e8aa751d64c9c09ce8ba6c1bbbd30 Reviewed-on: https://code.wireshark.org/review/34530 Tested-by: Petri Dish Buildbot Petri-Dish: Peter Wu <peter@lekensteyn.nl> Reviewed-by: Peter Wu <peter@lekensteyn.nl>
2019-09-15wsutil: Respect working directory on WindowsTomasz Moń1-1/+1
Pass working directory parameter to win32_create_process() in ws_pipe_spawn_sync(). Change-Id: I0abbc4fbf733138b20c2a34845b147530417c91e Reviewed-on: https://code.wireshark.org/review/34533 Petri-Dish: Michael Mann <mmann78@netscape.net> Tested-by: Petri Dish Buildbot Reviewed-by: Michael Mann <mmann78@netscape.net>
2019-09-06wsjson.c: do not leak memory when checking input buffer in json_validate()Pascal Quantin1-5/+5
Bug: 16039 Change-Id: Id3c22fbee87b5a8f5d2e4bc488ad902098fa5f05 Reviewed-on: https://code.wireshark.org/review/34459 Reviewed-by: Pascal Quantin <pascal@wireshark.org> Petri-Dish: Pascal Quantin <pascal@wireshark.org> Tested-by: Petri Dish Buildbot Reviewed-by: Jaap Keuter <jaap.keuter@xs4all.nl>
2019-09-03Also don't treat an empty buffer as JSON.Guy Harris1-3/+7
That also keeps us from looking at the non-existent first octet of an empty buffer. Bug: 16031 Change-Id: I3fcf4201d21dc44ccd8815cb0637c1eae4995560 Reviewed-on: https://code.wireshark.org/review/34439 Petri-Dish: Guy Harris <guy@alum.mit.edu> Tested-by: Petri Dish Buildbot Reviewed-by: Guy Harris <guy@alum.mit.edu>
2019-09-03Strengthen the JSON validator.Guy Harris1-0/+12
jsmn_parse() is handed a buffer and a count of octets in the buffer; it treats either running out of octets, as specified by the count, *OR* seeing a NUL as meaning "end of JSON string". That means that a buffer, of arbitrary size, the first octet of which is zero is a null string and considered valid JSON. That is clearly bogus; it messes up both tests for JSON files *and*, potentially, heuristic checks for JSON in packet payloads. Bug: 16031 Change-Id: I5ee78b613df3358f19787f2ce28ddc883368f03d Reviewed-on: https://code.wireshark.org/review/34438 Petri-Dish: Guy Harris <guy@alum.mit.edu> Tested-by: Petri Dish Buildbot Reviewed-by: Guy Harris <guy@alum.mit.edu>
2019-08-28Use g_hash_table_replace() when key depends on dataTomasz Moń1-1/+1
Using g_hash_table_insert() in cases where the key is contained within value is error prone. Use g_hash_table_replace() to eliminate the risk of ending up with incoherent hash table state. Change-Id: I595457476a2682e927d2c56b2692404aef4dc43a Reviewed-on: https://code.wireshark.org/review/34385 Reviewed-by: Michael Mann <mmann78@netscape.net> Petri-Dish: Michael Mann <mmann78@netscape.net> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>