aboutsummaryrefslogtreecommitdiffstats
path: root/wsutil
AgeCommit message (Collapse)AuthorFilesLines
2019-05-03CMake: Add libpcap imported library targetJoão Valverde1-2/+1
Change-Id: I5326b87784817fb353329e2d686fe0515c32f6cb Reviewed-on: https://code.wireshark.org/review/33038 Petri-Dish: João Valverde <j@v6e.pt> Tested-by: Petri Dish Buildbot Reviewed-by: Peter Wu <peter@lekensteyn.nl> Reviewed-by: João Valverde <j@v6e.pt>
2019-05-02Have the multiple-include guards cover everything.Guy Harris1-2/+2
Change-Id: Ibfb7b014fbffff64d1c4f179c452b4499c683481 Reviewed-on: https://code.wireshark.org/review/33050 Petri-Dish: Guy Harris <guy@alum.mit.edu> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
2019-05-02Move the Winsock initialization and cleanup to wsutil routines.Guy Harris3-0/+72
Those routines exist on both Windows and UN*X, but they don't do anything on UN*X (they could if it were ever necessary). That eliminates some #ifdefs, and also means that the gory details of initializing Winsock, including the Winsock version being requested, are buried in one routine. The initialization routine returns NULL on success and a pointer to a g_malloc()ated error message on failure; report the error to the user, along with a "report this to the Wireshark developers" suggestion. That means including wsutil/socket.h, which obviates the need to include some headers for socket APIs, as it includes them for you. Change-Id: I9327bbf25effbb441e4217edc5354a4d5ab07186 Reviewed-on: https://code.wireshark.org/review/33045 Petri-Dish: Guy Harris <guy@alum.mit.edu> Tested-by: Petri Dish Buildbot Reviewed-by: Guy Harris <guy@alum.mit.edu>
2019-05-01Windows: Modernize our WSAStartup usage.Gerald Combs1-1/+1
Make sure we link each application that calls WSAStartup with ws2_32.lib. Pass version 2.2 to WSAStartup. Wikipedia says it was introduced in 1996, so we should be OK. Ping-Bug: 15711 Change-Id: I431839e930e7c646669af7373789640b5180ec28 Reviewed-on: https://code.wireshark.org/review/33033 Petri-Dish: Gerald Combs <gerald@wireshark.org> Reviewed-by: Tomasz Moń <desowin@gmail.com> Tested-by: Petri Dish Buildbot Reviewed-by: Gerald Combs <gerald@wireshark.org>
2019-04-30wsutil: Fix 30 seconds freeze if process fails to startTomasz Moń1-0/+1
In ws_pipe_wait_for_pipe() on Windows, the WaitForMultipleObjects() waits on the pending pipe connection events and process handle. If the process handle is signalled, then it means that the process did exit without connecting to the pipes. The WaitForMultipleObjects() was not waiting on the process handle and thus if the process did fail without connecting to pipes the Wireshark gui was frozen for 30 seconds. This change fixes the freeze by increasing the number of handles, so WaitForMultipleObjects() is aware of the process handle. Change-Id: Id13824a60baf4be7795cbe1d5ed1c7932edbff45 Reviewed-on: https://code.wireshark.org/review/33028 Reviewed-by: Gerald Combs <gerald@wireshark.org>
2019-04-26file-util: fix possible null reference from code analysisGraham Bloice1-19/+21
Change-Id: I9b0c6b118b5f866abc969a437bbd9b9a28271bf0 Reviewed-on: https://code.wireshark.org/review/32841 Petri-Dish: Guy Harris <guy@alum.mit.edu> Reviewed-by: Graham Bloice <graham.bloice@trihedral.com> Petri-Dish: Graham Bloice <graham.bloice@trihedral.com> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
2019-04-25win32-utils: Do not share job between Wireshark instancesTomasz Moń1-1/+1
Creating Job Object named "Local\Wireshark child process cleanup" results in the job being shared between all Wireshark instances run within a single session. When two or more Wireshark instances were running, debug message appeared: "Could not assign child cleanup process: Access is denied. (5)" As the child process was not assigned to a job, it was possible that the child process was still active even after Wireshark did terminate. This fixes the issue by creating unnamed job object which is not shared. Change-Id: I59adc2aacff0151802163f155d68cbc8022c1479 Reviewed-on: https://code.wireshark.org/review/32985 Petri-Dish: Gerald Combs <gerald@wireshark.org> Tested-by: Petri Dish Buildbot Reviewed-by: Gerald Combs <gerald@wireshark.org>
2019-04-23ws_pipe: fix memory leaks in spawn arguments handlingPeter Wu2-81/+102
On Windows, ws_pipe_spawn_sync always leaks 'winargs', and leaks 'argv' on some error paths. Fix these and refactor the common argument parsing functionality to reduce duplication of functionality. Change-Id: I8fa5ca45aec20b53f6fa243b0dd07241a345f7ab Reviewed-on: https://code.wireshark.org/review/32932 Petri-Dish: Peter Wu <peter@lekensteyn.nl> Tested-by: Petri Dish Buildbot Reviewed-by: Tomasz Moń <desowin@gmail.com> Reviewed-by: Peter Wu <peter@lekensteyn.nl>
2019-04-22ws_pipe: fix return value of ws_pipe_spawn_async on error pathPeter Wu1-3/+3
The function returns a GPid, not a gboolean. Callers (mmdbresolv and extcap) only assume WS_INVALID_PID to be invalid (as documented). Change-Id: I40b491272a451f569864fa3259009d6d3fcce772 Fixes: v2.5.1rc0-413-g1a0987904f ("Generalize our process spawning code.") Reviewed-on: https://code.wireshark.org/review/32933 Petri-Dish: Peter Wu <peter@lekensteyn.nl> Tested-by: Petri Dish Buildbot Reviewed-by: Tomasz Moń <desowin@gmail.com> Reviewed-by: Anders Broman <a.broman58@gmail.com>
2019-04-21wsutil: Refactor WIN32 ws_pipe_wait_for_pipe()Tomasz Moń1-54/+75
The ws_pipe_wait_for_pipe() implementation had multiple issues: * Use auto-reset events with ConnectNamedPipe (should be manual-reset) * Leaking event handles * Not checking return value from CreateEvent() * Waiting on closed handles This change fixes all the above mentioned issues. Bug: 15696 Change-Id: Ia0c389a902655f85eccb0c59288b4a7d49da48c9 Reviewed-on: https://code.wireshark.org/review/32896 Petri-Dish: Guy Harris <guy@alum.mit.edu> Tested-by: Petri Dish Buildbot Reviewed-by: Tomasz Moń <desowin@gmail.com> Reviewed-by: Anders Broman <a.broman58@gmail.com>
2019-04-19wsutil: use environment variable WIRESHARK_EXTCAP_DIR when possiblePeter Wu1-40/+31
The WIRESHARK_EXTCAP_DIR environment variable is currently only used on Windows, and on UN*X when not running from the build directory. In order to avoid copying the sampleif.py test utility to the program directory, let's prioritize the environment variable over the build directory. Update the outdated comments while at it, the version directory has been removed long time ago. (The comments are based on the one for plugins.) This also fixes the test suite on macOS where the extcap subdirectory is located in the appbundle directory and not the build directory. Change-Id: I329bb233b1dd0b9c1422c2ebd60a6455347e1d62 Reviewed-on: https://code.wireshark.org/review/32890 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>
2019-04-18wsutil: Warn on empty argumentsTomasz Moń1-2/+8
Callers should not include empty strings in arguments list. Log warning message instead of silently dropping remaining arguments. Change-Id: Ia68c7b90cec860e032f81a4008aa005b07ebcfd5 Ping-Bug: 15586 Reviewed-on: https://code.wireshark.org/review/32849 Petri-Dish: Anders Broman <a.broman58@gmail.com> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
2019-04-15wsutil: Read stderr and stdout data asynchronouslyTomasz Moń1-40/+178
This significantly reduces the initialization time when system is using small pipe buffers. No time is lost on periodic process status checks as WaitForMultipleObjects() returns when the stdout/stderr data was read and/or when process finishes. Bug: 14657 Change-Id: I61fabf986577db7102a3136df83d2d92c7156727 Reviewed-on: https://code.wireshark.org/review/32773 Petri-Dish: Anders Broman <a.broman58@gmail.com> Tested-by: Petri Dish Buildbot Reviewed-by: Tomasz Moń <desowin@gmail.com> Reviewed-by: Anders Broman <a.broman58@gmail.com>
2019-04-10wsutil: Fix pipe handle leaks on WindowsTomasz Moń1-0/+11
If the PATHEXT environment variable contains .py and extcap is enabled, then Wireshark did leak 2 pipes for every .py file present in the extcap directory (regardless if there was .bat wrapper for it or not). Bug: 15689 Change-Id: Iae402c0075ee8155a7205a59711bbae734da7e9e Reviewed-on: https://code.wireshark.org/review/32812 Tested-by: Petri Dish Buildbot Reviewed-by: Guy Harris <guy@alum.mit.edu>
2019-04-10ieee80211: Fix some coverity scan issuesMikael Kanstrup1-2/+2
Fix coverity scan issues: - Insecure data handling (CID 1444231) - Unchecked return value (CID 1444234) Introduced by: 9cf77ec5e1 ieee80211: Support decrypting WPA3-Personal / SAE captures Change-Id: I8eb581750d2b0519f03f92873433f79409b0386b Reviewed-on: https://code.wireshark.org/review/32546 Petri-Dish: Alexis La Goutte <alexis.lagoutte@gmail.com> Tested-by: Petri Dish Buildbot Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
2019-03-24Add routines to return "Please report this as a bug" message strings.Guy Harris3-0/+70
(Routines, so that if we internationalize strings not in the Qt code, this can return the appropriately translated version.) Change-Id: I1c169d79acde2f0545af7af2a737883d58f52509 Reviewed-on: https://code.wireshark.org/review/32549 Petri-Dish: Guy Harris <guy@alum.mit.edu> Tested-by: Petri Dish Buildbot Reviewed-by: Guy Harris <guy@alum.mit.edu>
2019-03-23wsgcrypt: fix wrong double assignment (CID: 1444233).Dario Lombardo1-2/+1
Change-Id: Iaff0f7c6cc24286dcf48330088b1ba9a3f5dd18e Reviewed-on: https://code.wireshark.org/review/32541 Petri-Dish: Dario Lombardo <lomato@gmail.com> Petri-Dish: Anders Broman <a.broman58@gmail.com> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
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-03-22wsgcrypt: fix build with older gcrypts.Jeff Morriss1-2/+6
Fixes 9cf77ec5e12e24f1a8c6eb9fa14c015b830f066b. Change-Id: Ie90ce25995707d88995c243cb7b2d5013c3a4c28 Reviewed-on: https://code.wireshark.org/review/32522 Petri-Dish: Jeff Morriss <jeff.morriss.ws@gmail.com> Tested-by: Petri Dish Buildbot Reviewed-by: Jeff Morriss <jeff.morriss.ws@gmail.com>
2019-03-21ieee80211: Support decrypting WPA3-Personal / SAE capturesMikael Kanstrup2-0/+25
Add support for decrypting IEEE 802.11 WPA3-Personal / SAE traffic. SAE uses AES encryption but a different key derivation function (KDF) making Wireshark fail to decrypt such captures. Also both KDF and decryption method is determined based only on EAPOL key description version. This is not enough to figure out that SAE is being used. Implement the alternative KDF needed to derive valid PTK. Also implement a function to parse pairwise + group cipher suites and auth key management type from RSNE tag. Using this new function together with a number of new cipher and AKM lookup functions correct KDF for SAE can be selected. Bug: 15621 Change-Id: I8f6c917af1c9642c276a244943dd35f850ee3757 Reviewed-on: https://code.wireshark.org/review/32485 Petri-Dish: Anders Broman <a.broman58@gmail.com> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
2019-03-10Dumpcap: Set a bigger IO buffer (64KiB).Anders Broman1-0/+3
Set a bigger IO buffer to avoid syscall overhead. See https://github.com/the-tcpdump-group/libpcap/issues/792 Change-Id: If370da5ab2b70a9d0c925dd7c4c5c135c675c3f6 Reviewed-on: https://code.wireshark.org/review/31326 Petri-Dish: Anders Broman <a.broman58@gmail.com> Tested-by: Petri Dish Buildbot Reviewed-by: Guy Harris <guy@alum.mit.edu> Reviewed-by: Anders Broman <a.broman58@gmail.com>
2019-02-13macOS: Fix our plugin path.Gerald Combs1-2/+2
In CMake we only used PROJECT_RELEASE_VERSION to construct our plugin path, so rename it to PLUGIN_PATH_ID. Use a dash to separate version numbers on macOS in order to allow code signing and a period elsewhere. In the C code we only used VERSION_RELEASE to construct our plugin path, so rename it to PLUGIN_PATH_ID. Change-Id: I02abc591d7857269e8d47b414b61df4b28a25f2d Reviewed-on: https://code.wireshark.org/review/32013 Petri-Dish: Gerald Combs <gerald@wireshark.org> Reviewed-by: Guy Harris <guy@alum.mit.edu> Tested-by: Petri Dish Buildbot Reviewed-by: Gerald Combs <gerald@wireshark.org>
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 Wu2-1/+24
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-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>