aboutsummaryrefslogtreecommitdiffstats
path: root/extcap.c
AgeCommit message (Collapse)AuthorFilesLines
2018-03-02More spawned process handling updates.Gerald Combs1-6/+7
Document ws_pipe.h. Define invalid PIDs in one place. Extcap didn't use stdin before 1a0987904f. Make sure we close it. Change-Id: I7a69cd9b5137ae82435e64628a22e4d812d58f89 Reviewed-on: https://code.wireshark.org/review/26226 Petri-Dish: Gerald Combs <gerald@wireshark.org> Tested-by: Petri Dish Buildbot Reviewed-by: Gerald Combs <gerald@wireshark.org>
2018-03-02Generalize our process spawning code.Gerald Combs1-37/+34
Move the contents of extcap_spawn to ws_pipe. Rename various extcap_* prefixes to ws_pipe_*. Open stdin when we spawn processes. Change-Id: I9286295443ee955bb6328b0ed6f945ee0bb2a798 Reviewed-on: https://code.wireshark.org/review/26216 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-03-01Simplify the mode passed to CreateNamedPipe().Guy Harris1-4/+10
There's one mode you use if byte_mode is true, and another mode you use if it's false. My head hurts when I try to pretend to be a top-down parser for C and feed myself the existing expression, and Visual Studio Code Analyzer says "are you sure that's what you had in mind?", so I'm guessing the modes are: byte mode: PIPE_TYPE_BYTE | PIPE_READMODE_BYTE | PIPE_WAIT not byte mode: PIPE_TYPE_MESSAGE | PIPE_READMODE_MESSAGE | PIPE_WAIT and am just using one test of byte_mode to choose between them. Put the entire function under an #ifdef, so we can mark the byte_mode argument as unused on UN*X but not on Windows. Change-Id: Ib2d0b80f870b1789c1375ccb017bd90e93dca5ce Reviewed-on: https://code.wireshark.org/review/26201 Petri-Dish: Guy Harris <guy@alum.mit.edu> Tested-by: Petri Dish Buildbot Reviewed-by: Guy Harris <guy@alum.mit.edu>
2018-02-08replace SPDX identifier GPL-2.0+ with GPL-2.0-or-later.Dario Lombardo1-1/+1
The first is deprecated, as per https://spdx.org/licenses/. Change-Id: I8e21e1d32d09b8b94b93a2dc9fbdde5ffeba6bed Reviewed-on: https://code.wireshark.org/review/25661 Petri-Dish: Anders Broman <a.broman58@gmail.com> Petri-Dish: Dario Lombardo <lomato@gmail.com> Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-01-14extcap: check preference in extcap_ensure_interface().Dario Lombardo1-0/+3
Change-Id: I2b854b410e54b9f85ce26212d908c474f4611929 Reviewed-on: https://code.wireshark.org/review/25289 Petri-Dish: Dario Lombardo <lomato@gmail.com> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-01-14extcap: check preference in extcap_loaded_interfaces().Dario Lombardo1-0/+3
Change-Id: Ie1fd214eb8f9d55f1ce400b7227ad9887f05da76 Reviewed-on: https://code.wireshark.org/review/25286 Petri-Dish: Dario Lombardo <lomato@gmail.com> Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-01-12extcap: add more checks for extcap disabled.Dario Lombardo1-0/+6
Change-Id: I914efbb4293518a8a3f8aaa8739c9915c63d941c Reviewed-on: https://code.wireshark.org/review/25278 Petri-Dish: Roland Knall <rknall@gmail.com> Reviewed-by: Roland Knall <rknall@gmail.com> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-01-09extcap: add preference to prevent interfaces loading.Dario Lombardo1-0/+3
Change-Id: Ia5865a40c75e582f28408a0515c5c0b38e43a916 Reviewed-on: https://code.wireshark.org/review/25188 Reviewed-by: Stig Bjørlykke <stig@bjorlykke.org> Petri-Dish: Dario Lombardo <lomato@gmail.com> Tested-by: Petri Dish Buildbot Reviewed-by: Roland Knall <rknall@gmail.com>
2017-12-23Put special pipe-handling code into libwsutil.Guy Harris1-56/+4
Ask, in a comment, why we're doing PeekNamedPipe() when we're trying to read everyting in the pipe, up to the EOF, into a string. On UN*X, do the same "read up to an EOF and then NUL-terminate the result" stuff that we did on Windows; nothing guarantees that, on all UN*Xes, in all circumstances, until the end of time, world without end, amen, we can do one read and get the entire string. Change-Id: I578802b23fec1051139eaefd9a09fe2a6de06a11 Reviewed-on: https://code.wireshark.org/review/24959 Petri-Dish: Guy Harris <guy@alum.mit.edu> Tested-by: Petri Dish Buildbot Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-12-23extcap: null terminate the string that will be used in strlen (CID 1364684).Dario Lombardo1-1/+7
Change-Id: Ie4c7eed2ac24327292af9a45ffc7e4630338a6b4 Reviewed-on: https://code.wireshark.org/review/24948 Petri-Dish: Dario Lombardo <lomato@gmail.com> Tested-by: Petri Dish Buildbot Reviewed-by: Michael Mann <mmann78@netscape.net>
2017-12-21NULL check some g_log statements for extcap.Michael Mann1-4/+7
"Yes, on *most* UN*Xes, that causes "(null)" to be printed, but it causes a crash on at least some versions of Solaris, so Don't Do It." - Guy Harris Bug: 14194 Change-Id: Iff0d59803d78b1e87a564e8bcdc5c84af485eea6 Reviewed-on: https://code.wireshark.org/review/24922 Petri-Dish: Michael Mann <mmann78@netscape.net> Tested-by: Petri Dish Buildbot Reviewed-by: Michael Mann <mmann78@netscape.net>
2017-11-09Start using SPDX license identifiers.Gerald Combs1-13/+1
A while back Graham pointed out the SPDX project (spdx.org), which is working on standardizing license specifications: https://www.wireshark.org/lists/wireshark-dev/201509/msg00119.html Appendix V of the specification describes a short identifier (SPDX-License-Identifier) that you can use in place of boilerplate in your source files: https://spdx.org/spdx-specification-21-web-version#h.twlc0ztnng3b Start the conversion process with our top-level C and C++ files. Change-Id: Iba1d835776714deb6285e2181e8ca17f95221878 Reviewed-on: https://code.wireshark.org/review/24302 Reviewed-by: Gerald Combs <gerald@wireshark.org> Petri-Dish: Gerald Combs <gerald@wireshark.org> Reviewed-by: Balint Reczey <balint@balintreczey.hu> Tested-by: Petri Dish Buildbot Reviewed-by: Michael Mann <mmann78@netscape.net>
2017-08-31extcap: fix parameters save in preferences filePascal Quantin1-10/+0
Since g583150198b, extcap_arg structures holds a pointer to the current preference value. So let's not update its value outside of the prefs API otherwise the call to prefs_set_string_value() with pref_current done afterwards will never notify the change and the updated value will not be written in the preference file. Moreover update ExtcapArgument::resetValue() method to have an empty string instead of a NULL pointer. Otherwise prefs_set_string_value() will not notify the change and save the restored default value in the preference file either. Change-Id: Ie70e79d471c75e25705c7654e420a7706ebc4032 Reviewed-on: https://code.wireshark.org/review/23308 Petri-Dish: Pascal Quantin <pascal.quantin@gmail.com> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Dario Lombardo <lomato@gmail.com> Reviewed-by: Anders Broman <a.broman58@gmail.com>
2017-08-29extcap: check that argument parameter is not null before adding it to ↵Pascal Quantin1-1/+1
command line Without this test, we add an argument with an empty parameter Bug: 14006 Change-Id: I7e5313f652691808735f54b533cf5a7f7adeeae1 Reviewed-on: https://code.wireshark.org/review/23271 Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com> Petri-Dish: Pascal Quantin <pascal.quantin@gmail.com> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Dario Lombardo <lomato@gmail.com>
2017-08-28iface_lists: Access ifaces member by referenceMikael Kanstrup1-94/+84
Change access of ifaces elements from by val to by reference. With this change unnecessary copying of the whole struct is avoided but even more important is that elements no longer have to be removed and inserted whenever data is updated. This change aims to make it more clear that ifaces elements shall never directly be removed from the array. Instead use function capture_opts_del_iface NOTE: Code for GTK UI not updated Ping-Bug: 13864 Change-Id: I04b65d5ee36526b30d959b8e5a2a48a3c7c4f15b Reviewed-on: https://code.wireshark.org/review/23204 Reviewed-by: Anders Broman <a.broman58@gmail.com>
2017-08-28extcap: Interface Toolbar support on WindowsHåkon Øye Amundsen1-10/+45
Add support for extcap control pipes on Windows. Improved read loop in InterfaceToolbarReader. Delay opening control pipes until extcap has opened the fifo pipe. Make extcap_example.py work on Windows. Bug: 13833 Change-Id: I4b47d25452637759b8a3be53be48eee5365bc0e4 Reviewed-on: https://code.wireshark.org/review/23211 Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Anders Broman <a.broman58@gmail.com>
2017-08-23extcap: Create unique pipe names for each interfaceStig Bjørlykke1-22/+22
On Windows the pipe names does not get random characters appended. Add the interface name and pipe type to make it unique. This partly fixes the issue with capturing from multiple extcap interfaces on Windows. Ping-Bug: 13653 Ping-Bug: 13833 Change-Id: I4290b37cf789bf77608993682a803aca29513d28 Reviewed-on: https://code.wireshark.org/review/23158 Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Anders Broman <a.broman58@gmail.com>
2017-08-22Add hardware timestamping supportAhmad Fatoum1-0/+1
pcap provides a pcap_set_tstamp_type function, which can be used to request hardware timestamps from a supporting kernel. This patch adds support for aforementioned function as well as two new command line options to dumpcap, wireshark and tshark: --list-time-stamp-types List time stamp types supported for the interface --time-stamp-type <type> Change the interface's timestamp method Name choice mimics those used by tcpdump(1), which already supports this feature. However, unlike tcpdump, we provide both options unconditionally. If Wireshark was configured without pcap_set_tstamp_type being available, --list-time-stamp-types reports an empty list. Change-Id: I418a4b2b84cb01949cd262aad0ad8427f5ac0652 Signed-off-by: Ahmad Fatoum <ahmad.fatoum@siemens.com> Reviewed-on: https://code.wireshark.org/review/23113 Petri-Dish: Guy Harris <guy@alum.mit.edu> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Anders Broman <a.broman58@gmail.com>
2017-08-15extcap: use options as they are shown in the dialog.Dario Lombardo1-18/+8
Bug: 13051 Change-Id: I287a4e1d529cc281aaae4a786010358c108d5f93 Reviewed-on: https://code.wireshark.org/review/22933 Petri-Dish: Roland Knall <rknall@gmail.com> Petri-Dish: Dario Lombardo <lomato@gmail.com> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Anders Broman <a.broman58@gmail.com>
2017-06-30extcap: another round of memory leak fixesPeter Wu1-4/+14
Fix assorted memory leaks. Note that _tool_for_ifname is cleaned up at exit by extcap_cleanup, but lacked key/value destructors, so add them. After this, ASAN reports no more extcap memleaks. Change-Id: Ie5f4b1e2453a0beb52d617670202973839ca1416 Reviewed-on: https://code.wireshark.org/review/22466 Petri-Dish: Anders Broman <a.broman58@gmail.com> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Anders Broman <a.broman58@gmail.com>
2017-05-30Qt: Add support to verify extcap capture filterMichael Mann1-0/+49
Bug: 11668 Change-Id: Ib218d87c1905e53ffdab4e3dd6f93ba2c3d07c8b Reviewed-on: https://code.wireshark.org/review/21770 Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Michael Mann <mmann78@netscape.net> Reviewed-by: Roland Knall <rknall@gmail.com>
2017-05-03Extcap: use glib-compat for g_list_free_full()Martin Mathieson1-0/+1
Change-Id: I13e6a465b0e169f2f4ce134df3c873c416737b33 Reviewed-on: https://code.wireshark.org/review/21476 Petri-Dish: Martin Mathieson <martin.r.mathieson@googlemail.com> Reviewed-by: Peter Wu <peter@lekensteyn.nl> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Michael Mann <mmann78@netscape.net>
2017-04-29extcap_free_interface_info: data param is usedMartin Kaiser1-1/+1
The data parameter is used, remove the _U_ qualifier. Change-Id: I3a3935bae958103da1a7a1abe0636e4781424aa7 Reviewed-on: https://code.wireshark.org/review/21408 Reviewed-by: Martin Kaiser <wireshark@kaiser.cx>
2017-04-25Qt: Add interface toolbar supportStig Bjørlykke1-2/+169
An extcap utility can provide configuration for controls to use in a GUI interface toolbar. This controls are bidirectional and can be used to control the extcap utility while capturing. This is useful in scenarios where configuration can be done based on findings in the capture process, setting temporary values or give other inputs without restarting current capture. Todo: - Add support for Windows Change-Id: Ie15fa67f92eb27d8b73df6bb36f66b9a7d81932d Reviewed-on: https://code.wireshark.org/review/19982 Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Stig Bjørlykke <stig@bjorlykke.org>
2017-04-19extcap: fix memory leakMax Dmitrichenko1-1/+1
found by valgrind Change-Id: I8c5226a08be797ce72ec937138a6681d946fb13c Reviewed-on: https://code.wireshark.org/review/20720 Petri-Dish: Michael Mann <mmann78@netscape.net> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Roland Knall <rknall@gmail.com>
2017-03-27Don't waste time trying to run non-plain file and non-executable files.Guy Harris1-11/+17
Directories, and non-executable files, aren't going to be extcap executables. This may not make much of a difference for an installed version of Wireshark, but it makes a difference if you're running from the build directory. Change-Id: Ib9953fa04392dc7a8420ddf28bab9726e6050c12 Reviewed-on: https://code.wireshark.org/review/20752 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-03-04extcap: Minor improvementsRoland Knall1-14/+46
Add method for searching for tools by ifname and minor improvements in the interface callback to save time and space Change-Id: I0073c96fbee846cc5ff6304823fa14564ff36c22 Reviewed-on: https://code.wireshark.org/review/20376 Petri-Dish: Roland Knall <rknall@gmail.com> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Roland Knall <rknall@gmail.com>
2017-03-01extcap: Create callback structureRoland Knall1-32/+56
To ease development of callbacks and new parameters, move all parameters for the callback methods to a struct Change-Id: I160277acf4d0473897172124f7c7aa744718da9c Reviewed-on: https://code.wireshark.org/review/20316 Petri-Dish: Roland Knall <rknall@gmail.com> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Roland Knall <rknall@gmail.com>
2017-02-27extcap: remove leak in interface lists.Dario Lombardo1-2/+14
Change-Id: Ib57292afc88cd32736b78a901385cfdde84c46c9 Reviewed-on: https://code.wireshark.org/review/20297 Reviewed-by: Roland Knall <rknall@gmail.com> Petri-Dish: Roland Knall <rknall@gmail.com> Reviewed-by: Dario Lombardo <lomato@gmail.com>
2017-02-22extcap: Reduce number of scans and storageRoland Knall1-212/+266
Reduce the number of storage arrays and the number of necessary loads. Also include cleaner methods for reloading the interfaces and cleanly reload if asked by the overall system Change-Id: I529465ec2593d40c955c6cdeaf3a85e3021c0596 Reviewed-on: https://code.wireshark.org/review/20230 Petri-Dish: Roland Knall <rknall@gmail.com> Reviewed-by: Stig Bjørlykke <stig@bjorlykke.org> Reviewed-by: Roland Knall <rknall@gmail.com>
2017-02-03extcap: destroy hash tables on exit.Dario Lombardo1-0/+10
Change-Id: Ia6a1d8a45c36aff7f2bea8bde2ed5f308bddd2e1 Reviewed-on: https://code.wireshark.org/review/19919 Petri-Dish: Roland Knall <rknall@gmail.com> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Dario Lombardo <lomato@gmail.com> Reviewed-by: Roland Knall <rknall@gmail.com>
2017-01-22Internalize struct preferenceMichael Mann1-1/+0
Move "struct preference" into prefs.c, essentially creating a "private" structure to handle preferences. The 2 motivating factors were: 1. Better memory management so that clients/users of API don't have to worry about it. 2. Hide the ugliness of the union stuff and make it transparent to the API. A few bugs related to preference <-> Decode As integration were fixed while in the neighborhood. Change-Id: I509b9a236235d066b139c98222b701475e0ed365 Reviewed-on: https://code.wireshark.org/review/19578 Petri-Dish: Michael Mann <mmann78@netscape.net> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Anders Broman <a.broman58@gmail.com>
2017-01-12Extcap: Restore previously created preference from hash table, not ↵Michael Mann1-2/+2
preference pointer Change-Id: Ie68a5c6c193f362e78d4f4b1f20edf7747e2313f Reviewed-on: https://code.wireshark.org/review/19614 Petri-Dish: Michael Mann <mmann78@netscape.net> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Roland Knall <rknall@gmail.com>
2017-01-04Include extcap binaries in the count of things to point out during startup.Guy Harris1-2/+33
The GTK+ version, at least, crashes if there are more "doing XXX..." items put up than the calculated count, so, now that we're putting up items for extcap binaries, we need to count the extcap binaries. Clean up some stuff we found doing this (indentation, a _U_ on something that's used). Change-Id: I1f88042b64ce4b9ae352de37689677c694e3770b Reviewed-on: https://code.wireshark.org/review/19549 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-12-14extcap: Avoid double free of help.Stig Bjørlykke1-2/+2
Avoid double free of help when having multiple extcap interfaces. Ping-Bug: 13218 Change-Id: I6a0d6afd645787f9814c02e84079b4e8763d05f1 Reviewed-on: https://code.wireshark.org/review/19261 Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org> Reviewed-by: Dario Lombardo <lomato@gmail.com>
2016-12-14extcap: set help for interfaces.Dario Lombardo1-0/+3
The help statement is in the first sentence, while interfaces are in others. We need to keep state of it. Ping-Bug: 13218 Change-Id: Iad1d403d5e8bc34e2489daaa3b14d469d5ee5b5b Reviewed-on: https://code.wireshark.org/review/19148 Petri-Dish: Dario Lombardo <lomato@gmail.com> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Roland Knall <rknall@gmail.com>
2016-12-08extcap: Whitespace cleanup.Stig Bjørlykke1-192/+367
Cleanup code to use uniform whitespace to make it more readable. Also added brackets to unbracketed one line conditional statements. This was done using "astyle -A1cHjk3pU". Change-Id: Iebe96c488c843ce1d790ede0016eb9df025e98a5 Reviewed-on: https://code.wireshark.org/review/19133 Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Peter Wu <peter@lekensteyn.nl> Reviewed-by: Michael Mann <mmann78@netscape.net>
2016-12-07extcap: Separate dirname and file with G_DIR_SEPARATOR_S.Stig Bjørlykke1-5/+1
Change-Id: I9e1e9b1a10a15ca95519392a7a19ba77f460141e Reviewed-on: https://code.wireshark.org/review/19131 Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Michael Mann <mmann78@netscape.net>
2016-10-22More checks for localtime() and gmtime() returning NULL.Guy Harris1-0/+4
And some comments in the case where we're converting the result of time() - if your machine's idea of time predates January 1, 1970, 00:00:00 UTC, it'll crash on Windows, but that's not a case where a *file* can cause the problem due either to a bad file time stamp or bad time stamps in the file. Change-Id: I837a438e4b875dd8c4f3ec2137df7a16ee4e9498 Reviewed-on: https://code.wireshark.org/review/18369 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-09-18extcap: fix management of multicheck and saved non boolean argumentsPascal Quantin1-4/+3
Launching USBPcap without going in the interface options menu exhibits 2 bugs: - we should restore a value only if it is not an empty string (otherwise USBPcap with an ampty --devices multicheck argument) - when building the argument list for a non boolean argument not using the default value, do not call g_strconcat. It will build a string concatenating the option and value (for example "--devices 1" that will be treated as a single argument). Instead option and value must be given separately to argument list. Bug: 12846 Change-Id: I5628cb264a7632089e6579e9ae7400e2c0e500e2 Reviewed-on: https://code.wireshark.org/review/17773 Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com> Petri-Dish: Pascal Quantin <pascal.quantin@gmail.com> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Roland Knall <rknall@gmail.com>
2016-09-17extcap: fix heap-use-after free after saving prefsPeter Wu1-1/+2
All strings passed to prefs must be valid for the lifetime of the program (before prefs_cleanup is called). Use wmem for this purpose. Fixes v2.3.0rc0-660-g26bf66f Change-Id: I94f3bbb8ac6e18ae59d6462525f6bbc46fdb0f1f Reviewed-on: https://code.wireshark.org/review/17737 Petri-Dish: Peter Wu <peter@lekensteyn.nl> Reviewed-by: Stig Bjørlykke <stig@bjorlykke.org> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Peter Wu <peter@lekensteyn.nl>
2016-09-12Fix file name in comment.Guy Harris1-1/+1
Change-Id: I2a5b6e5c0ba8e729fbfa7e9e218aca1c747d6e45 Reviewed-on: https://code.wireshark.org/review/17667 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-09-12extcap: plug more memory leaksPeter Wu1-15/+23
Fix leak of the preference key name which happen for every new extcap argument. Fix leak of extcap arguments and the interface names in extcap_register_preferences. Change-Id: Idd68f924baa000303043cb98b32b23ce34fddb64 Reviewed-on: https://code.wireshark.org/review/17637 Petri-Dish: Peter Wu <peter@lekensteyn.nl> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Peter Wu <peter@lekensteyn.nl>
2016-09-12extcap: Fix misc memory leaks triggered by network interface changesMikael Kanstrup1-17/+43
Valgrind reports plenty of misc memory leaks in extcap after the network interface list has changed or is refreshed. Errors can be seen by starting Wireshark with Valgrind's memcheck tool and bringing a network interface up and down a few times with: ifconfig eth0 up ifconfig eth0 down Change-Id: I90f53847071854b7d02facb39b7a380732de79b4 Reviewed-on: https://code.wireshark.org/review/17606 Petri-Dish: Peter Wu <peter@lekensteyn.nl> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Peter Wu <peter@lekensteyn.nl>
2016-09-11extcap: fix use-after-free for preferencesPeter Wu1-29/+44
In commit v2.3.0rc0-117-g485bc45 (backported to v2.2.0rc0-44-g66721ca), extcap_prefs_dynamic_vals and extcap_cleanup were added in an attempt to address dangling pointers. Unfortunately it is not sufficient: - A pointer to the preference value is stored in extcap_arg and passed to the prefs API, but this extcap_arg structure can become invalid which result in use-after-free whenever the preference is accessed. - On exit, a use-after-free occurs in prefs_cleanup when the preference value is being checked. As the preference subsystem actually manages the memory for the string value and consumers should only provide a pointer where the value can be stored, convert the char* field in extcap to char**. This has as additional benefit that values are not limited to 256 bytes anymore. extcap_cleanup is moved after epan_cleanup to ensure that prefs_cleanup does not operate on dangling pointers. Crash is reproducible under ASAN with: tshark -i randpkt Ping-Bug: 12183 Change-Id: Ibf1ba1102a5633aa085dc278a12ffc05a4f4a34b Reviewed-on: https://code.wireshark.org/review/17631 Petri-Dish: Peter Wu <peter@lekensteyn.nl> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Roland Knall <rknall@gmail.com>
2016-09-08extcap_child_watch_cb() always uses the status argument.Guy Harris1-2/+2
Change-Id: I2537f2e3babe2158796acda6855f5aebeb0b7d4d Reviewed-on: https://code.wireshark.org/review/17595 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-09-07extcap: Add tool-specified helppageRoland Knall1-11/+19
Allow the tool to provide a link to a helppage, displayed by clicking on help in the configuration dialog. The URL will be opened using an URL based service, therefore local as well as remote URLs are possible. Change-Id: I58b30244e97919d5cf6892faf96536ddc30fb5a7 Reviewed-on: https://code.wireshark.org/review/17549 Reviewed-by: Roland Knall <rknall@gmail.com>
2016-09-06extcap:Replace self-organized lists with glib onesRoland Knall1-133/+53
Replace the error-prone next/prev handling with GList and GHashTable Cleanup extcap_parser to only expose necessary functions Remove token know-how from extcap Change-Id: I7cc5ea06f58ad6c7a85ac292f5d2cb3d33e59833 Reviewed-on: https://code.wireshark.org/review/17496 Reviewed-by: Anders Broman <a.broman58@gmail.com>
2016-08-15extcap: Fix Dereference of null pointerAlexis La Goutte1-11/+8
Change-Id: I03098de9bd8684953a4fe024a3e6b604eeecf03f Reviewed-on: https://code.wireshark.org/review/17066 Petri-Dish: Pascal Quantin <pascal.quantin@gmail.com> Reviewed-by: Dario Lombardo <lomato@gmail.com> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
2016-08-04extcap: preference name must only contain lower case ASCII, numbers, dots or ↵Pascal Quantin1-10/+30
underscores This chage set restores the normalization that was done before g485bc45. Without it, USBPcap extacp utility triggers a crash. Change-Id: Id960db186888452ec3d04df1ee48dcc3899e8951 Reviewed-on: https://code.wireshark.org/review/16871 Petri-Dish: Pascal Quantin <pascal.quantin@gmail.com> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Roland Knall <rknall@gmail.com>