Commit Graph

168 Commits

Author SHA1 Message Date
Michael Mann 4b3b3f5877 Extcap: Restore previously created preference from hash table, not 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-12 13:33:49 +00:00
Guy Harris 26430ff647 Include extcap binaries in the count of things to point out during startup.
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>
2017-01-04 22:10:48 +00:00
Stig Bjørlykke 07ffcf9042 extcap: Avoid double free of help.
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-14 14:35:30 +00:00
Dario Lombardo 1c2d224647 extcap: set help for interfaces.
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-14 10:12:43 +00:00
Stig Bjørlykke 6b064e0e14 extcap: Whitespace cleanup.
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-08 21:18:41 +00:00
Stig Bjørlykke fa47c368c6 extcap: Separate dirname and file with G_DIR_SEPARATOR_S.
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-12-07 19:46:49 +00:00
Guy Harris 10ca4c7527 More checks for localtime() and gmtime() returning NULL.
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-10-22 02:27:32 +00:00
Pascal Quantin 66203b4f31 extcap: fix management of multicheck and saved non boolean arguments
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-18 09:01:08 +00:00
Peter Wu 2c33f74bc6 extcap: fix heap-use-after free after saving prefs
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-17 10:44:23 +00:00
Guy Harris 84436438a8 Fix file name in comment.
Change-Id: I2a5b6e5c0ba8e729fbfa7e9e218aca1c747d6e45
Reviewed-on: https://code.wireshark.org/review/17667
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-09-12 16:52:17 +00:00
Peter Wu 26bf66f423 extcap: plug more memory leaks
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-12 12:14:46 +00:00
Mikael Kanstrup c64762d33c extcap: Fix misc memory leaks triggered by network interface changes
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-12 12:13:41 +00:00
Peter Wu 583150198b extcap: fix use-after-free for preferences
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-11 08:33:42 +00:00
Guy Harris bd45929ba6 extcap_child_watch_cb() always uses the status argument.
Change-Id: I2537f2e3babe2158796acda6855f5aebeb0b7d4d
Reviewed-on: https://code.wireshark.org/review/17595
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-09-08 20:43:28 +00:00
Roland Knall ee1a4109cf extcap: Add tool-specified helppage
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-07 09:09:30 +00:00
Roland Knall 9b39db04d3 extcap:Replace self-organized lists with glib ones
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-09-06 04:19:45 +00:00
Alexis La Goutte 5ebfbf4fec extcap: Fix Dereference of null pointer
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-15 20:52:07 +00:00
Pascal Quantin 0bf1288607 extcap: preference name must only contain lower case ASCII, numbers, dots or 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>
2016-08-04 11:27:19 +00:00
Michael Tuexen 18f775af55 Fix compilation on FreeBSD.
Includes are needed for using macros like WIFEXITED.

Change-Id: Ia09ca58eeab2d151a756d285b0aeb55141c4d24a
Reviewed-on: https://code.wireshark.org/review/16841
Reviewed-by: Michael Tüxen <tuexen@wireshark.org>
2016-08-02 12:33:52 +00:00
Roland Knall d62ad9dd47 extcap: Remove g_spawn_check_exit_status
This function is not supported in the min GLIB version, therefore
the code is to be removed

Change-Id: Ie39170bfc0662e5a477cbc45d7eadebcf2c70d4e
Reviewed-on: https://code.wireshark.org/review/16827
Petri-Dish: Roland Knall <rknall@gmail.com>
Reviewed-by: Dario Lombardo <lomato@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Roland Knall <rknall@gmail.com>
2016-08-02 11:16:16 +00:00
Dario Lombardo 867d7ca399 extcap: add null check (CID 1364683).
Change-Id: I1d81d6f043fa695ed507cf733fffa832922a708c
Reviewed-on: https://code.wireshark.org/review/16832
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>
2016-08-02 04:16:45 +00:00
Dario Lombardo abe8e51dbf extcap: extend buffer (CID 1364684).
Change-Id: I4ed6965fa1173b69d9e325bc814e382b5368d40c
Reviewed-on: https://code.wireshark.org/review/16831
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2016-08-02 04:15:19 +00:00
Roland Knall c611eded22 extcap: Use stderr to print error message
This patch reads out the stderr messages from an extcap
utility and displays it to an user. It was tested on Qt
but not on GTK, but should work their as well.

On Mac OS/X and Windows the child_watch does not behave
as it was intended. Therefore in extcap_cleanup, the callbacks
are called manually, if and only if, they have not been
called already.

The reason why it displays two error messages is, that
by the time the first one is being displayed, glib has not
returned from the spawned process on Linux yet. So there
is no way to add the stderr correctly, and putting a handler
to stderr into interface_opts will lead to memory errors,
cause then the code tries to access memory outside of its
protection.

Bug: 11892
Change-Id: I2db60dd480fed3e01428b91a705057e4f088bd15
Reviewed-on: https://code.wireshark.org/review/12954
Reviewed-by: Roland Knall <rknall@gmail.com>
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: Anders Broman <a.broman58@gmail.com>
2016-07-30 21:15:39 +00:00
Roland Knall 485bc456c5 extcap: Restore functionality for options
Allow stored options to be restored to their default values. This
adds a global cleanup method for extcap and globally defined
preference values, which fixes the parameter problem with windows

Change-Id: I48e0cf846ef81f4732d652c6a2ad0020db5df08e
Reviewed-on: https://code.wireshark.org/review/13741
Petri-Dish: Roland Knall <rknall@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Roland Knall <rknall@gmail.com>
2016-07-29 03:15:54 +00:00
Roland Knall f2786bc8ff extcap: Remove g_spawn_helper support
Move g_spawn to separate file and implement functions to
 use Windows based method of spawning, instead of the glib
 based version

Change-Id: Ibae03d834ec86531eba37dc8768fbf17ddadf57f
Reviewed-on: https://code.wireshark.org/review/16049
Petri-Dish: Roland Knall <rknall@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Graham Bloice <graham.bloice@trihedral.com>
Reviewed-by: Roland Knall <rknall@gmail.com>
2016-07-05 11:54:43 +00:00
Michael Mann acc018b8d1 Allow create_tempfile to support a suffix.
Ping-Bug: 10203
Change-Id: Ifa24870d711449b87e9839dd46af614e4aa28fde
Reviewed-on: https://code.wireshark.org/review/15608
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Martin Mathieson <martin.r.mathieson@googlemail.com>
2016-06-01 06:24:05 +00:00
Pascal Quantin ae316e2d88 Compile sshdump and ciscodump for Windows
Use libSSH 0.7.2 compiled with MinGW(32|64) and linked with zlib and gcrypt support

Change-Id: I7c17d1ba3dd1890e2f83c119f5ea851834807e43
Reviewed-on: https://code.wireshark.org/review/12117
Petri-Dish: Pascal Quantin <pascal.quantin@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2016-04-25 07:22:28 +00:00
Dario Lombardo 20e7accf8c extcap: fix const compiler warnings.
Change-Id: I849b16597829212b195bd75a2aab8e1db49f1ccf
Reviewed-on: https://code.wireshark.org/review/14827
Reviewed-by: Roland Knall <rknall@gmail.com>
Petri-Dish: Roland Knall <rknall@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2016-04-19 01:42:19 +00:00
João Valverde 52dd4fb633 Fix building without extcap enabled
Using cmake -DENABLE_EXTCAP=no or ./configure --without-extcap.

Some documentation fixes too.

Change-Id: Iebf9c843d67e10a32de1a62904de8f88b872ec99
Reviewed-on: https://code.wireshark.org/review/14522
Petri-Dish: João Valverde <j@v6e.pt>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: João Valverde <j@v6e.pt>
2016-03-21 17:10:21 +00:00
Guy Harris 842a9b5100 Replace extcap_interface_list() with append_extcap_interface_list().
Pull the "rebuild the list of extcap interfaces and, optionally, return
a list of if_infos for them" into a separate
extcap_reload_interface_list() routine, call it in the cases where we
don't want the if_infos list, and have append_extcap_interface_list()
call it, asking it for the if_infos list, and then append the interfaces
to that list.

Change-Id: I07478ab133859484b3e0916144971639f961224b
Reviewed-on: https://code.wireshark.org/review/14189
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-02-27 01:04:33 +00:00
Guy Harris 60f87ca919 Put the extcap interfaces at the *end* of the interface list.
The list should start with the native local interfaces, as returned by
pcap, so that we default to the interface pcap gives first, rather than
to whatever extcap interface happens to be at the beginning.

This also means that, if we're only calling extcap_interface_list() to
regenerate our internal data structures, we don't bother allocating -
and leaking! - a list of if_info structures.

Change-Id: Ida651b5b081883f118a300b9f57403f2dc5c4363
Ping-Bug: 12183
Reviewed-on: https://code.wireshark.org/review/14187
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-02-27 00:37:22 +00:00
Guy Harris c5c10581b6 Clean up setting *err_str to NULL.
Just do it upfront.

Change-Id: I5305882b8efd080fcb3e8ea626e09f4682729702
Reviewed-on: https://code.wireshark.org/review/14185
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-02-26 23:29:44 +00:00
Guy Harris 9253791648 Fix indentation.
Change-Id: I201c35e1f6dfdb67a68dbc0ee684e0231842f00b
Reviewed-on: https://code.wireshark.org/review/14182
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-02-26 22:56:28 +00:00
Roland Knall 3f43b1df44 extcap: Fix call to child watch
Child watch seems to keep executables in limbo, if extcap_cleanup
removed the watch before it could be fired at least once

Bug: 12080
Change-Id: I74afafe8545d464ec08b1043a6377a6450e4c772
Reviewed-on: https://code.wireshark.org/review/13900
Petri-Dish: Roland Knall <rknall@gmail.com>
Reviewed-by: Michal Labedzki <michal.labedzki@tieto.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Roland Knall <rknall@gmail.com>
2016-02-11 08:49:54 +00:00
Mikael Kanstrup 7a1eca1726 extcap: Convert settings to preference friendly key names
Preferences are only allowed to contain lowercase ASCII letters,
numbers, underscores or dot characters. Create a utility function
to convert an extcap setting to its equivalent preference key and
use it wherever conversion from setting to preference key is needed.

Bug: 12064
Change-Id: I39bbac7de5f0f905bd41c54257fa997a3b32442d
Reviewed-on: https://code.wireshark.org/review/13687
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-02-11 06:40:16 +00:00
Mikael Kanstrup a53ab9dfcc Fix leaks when spawning extcap processes
Valgrind reports leaks like these when spawning extcap processes (for
example when displaying or refreshing interface list with extcap
interfaces present):

3,917 (464 direct, 3,453 indirect) bytes in 29 blocks are definitely lost in loss record 58,301 of 58,638
   at 0x4C2AB80: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
   by 0xA6D2610: g_malloc (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4002.0)
   by 0xA6E822D: g_slice_alloc (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4002.0)
   by 0xA6B913B: g_error_new_valist (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4002.0)
   by 0xA6B94ED: g_set_error (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4002.0)
   by 0xA710B03: ??? (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4002.0)
   by 0xA710E17: g_spawn_sync (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4002.0)
   by 0x44C677: extcap_foreach (extcap.c:199)
   by 0x44CCAD: extcap_interface_list (extcap.c:413)
   by 0x72B548: capture_interface_list (capture_ifinfo.c:126)
   by 0x7336FA: scan_local_interfaces (iface_lists.c:141)
   by 0x55F01F: WiresharkApplication::refreshLocalInterfaces() (wireshark_application.cpp:898)
   ...

Change-Id: If8f750f5f8fa42a6f0884bb0e6bbbd71bd8f68aa
Reviewed-on: https://code.wireshark.org/review/13631
Petri-Dish: Roland Knall <rknall@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Roland Knall <rknall@gmail.com>
2016-02-01 20:36:37 +00:00
Roland Knall 71a21d79cf extcap: Correct save for file arguments
Also add check to has_configuration

Change-Id: Ia0ffbd3bf68ad51c26bc75b5ee179db179e22bd4
Reviewed-on: https://code.wireshark.org/review/13635
Reviewed-by: Roland Knall <rknall@gmail.com>
2016-02-01 12:14:44 +00:00
Roland Knall 927ffaa794 extcap: Add Save functionality to options dialog
This patch creates the functionality of saving all parameters
for extcap devices in the general preference section.

For now, multiselect and fileselect do not save their values
but patches for this will be provided in the future

Also, all preferences are stored as strings to make handling
easier. This might change in the future, but for the first version
it will stick.

Restore to Defaults is not implemented as of yet, and will be
in a future version, once the preference storing is finalized

Bug: 11666
Change-Id: I178346405146d2e43f4f3481c05c92c0b3595af5
Reviewed-on: https://code.wireshark.org/review/13451
Petri-Dish: Roland Knall <rknall@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Roland Knall <rknall@gmail.com>
2016-02-01 12:12:41 +00:00
Mikael Kanstrup 96acb62c82 Fix memleaks on interface refresh when extcap configs exists
If there are extcap interfaces present then each time the capture
interfaces list is displayed or refreshed a number of extcap related
allocations are leaked.

Valgrind reports leaks like these:

2,007 (144 direct, 1,863 indirect) bytes in 6 blocks are definitely lost in loss record 64,328 of 65,138
   at 0x4C2AB80: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
   by 0xA6D2610: g_malloc (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4002.0)
   by 0xA6E822D: g_slice_alloc (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4002.0)
   by 0xA6C94F3: g_list_append (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4002.0)
   by 0x44C9AF: search_cb (extcap.c:451)
   by 0x44C6FC: extcap_foreach (extcap.c:204)
   by 0x44CDFF: extcap_get_if_configuration (extcap.c:473)
   by 0x44CE3C: extcap_has_configuration (extcap.c:489)
   by 0x654356: InterfaceTree::display() (interface_tree.cpp:199)
   by 0x6547DF: InterfaceTree::getInterfaceList() (interface_tree.cpp:252)
   by 0xBFCF2A5: QMetaObject::activate(QObject*, int, int, void**) (in /usr/lib/x86_64-linux-gnu/libQt5Core.so.5.2.1)
   by 0x563F9A: WiresharkApplication::allSystemsGo() (wireshark_application.cpp:914)
   by 0x4478D9: main (wireshark-qt.cpp:1373)

9,126 (432 direct, 8,694 indirect) bytes in 18 blocks are definitely lost in loss record 58,524 of 58,638
   at 0x4C2AB80: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
   by 0xA6D2610: g_malloc (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4002.0)
   by 0xA6E822D: g_slice_alloc (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4002.0)
   by 0xA6C94F3: g_list_append (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.4002.0)
   by 0x44C9AF: search_cb (extcap.c:451)
   by 0x44C6FC: extcap_foreach (extcap.c:204)
   by 0x44CDFF: extcap_get_if_configuration (extcap.c:473)
   by 0x44CE3C: extcap_has_configuration (extcap.c:489)
   by 0x654356: InterfaceTree::display() (interface_tree.cpp:199)
   by 0xBFCF2A5: QMetaObject::activate(QObject*, int, int, void**) (in /usr/lib/x86_64-linux-gnu/libQt5Core.so.5.2.1)
   by 0x4A3214: MainWindow::on_actionCaptureRefreshInterfaces_triggered() (main_window_slots.cpp:3605)
   ...

Change-Id: I9433b8e36813cbef9dca5ab08074e985793f4d0d
Reviewed-on: https://code.wireshark.org/review/13617
Petri-Dish: Alexis La Goutte <alexis.lagoutte@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Roland Knall <rknall@gmail.com>
2016-01-31 10:48:53 +00:00
Dario Lombardo ff033c6a2f extcap: add masked to options.
This allows an option to be masked (like a password), by using
the argument-type password.

Change-Id: I2eae1be2e6672bff28ba5f749d7a3f687ebd4631
Reviewed-on: https://code.wireshark.org/review/13385
Reviewed-by: Dario Lombardo <lomato@gmail.com>
Petri-Dish: Roland Knall <rknall@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Roland Knall <rknall@gmail.com>
2016-01-18 15:04:33 +00:00
Stig Bjørlykke e3ab748b7d extcap: Code cleanup
Rewrote to avoid unneeded g_strdup/g_free constructs, made some
arguments const, simplified some code and fixed some whitespace.

Plugged a memory leak in extcap_free_info().

Change-Id: I0bfcd86e6464d8bc592329b05dc994191a430096
Reviewed-on: https://code.wireshark.org/review/13306
Petri-Dish: Roland Knall <rknall@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Roland Knall <rknall@gmail.com>
2016-01-16 08:50:27 +00:00
Roland Knall 75ff25f285 extcap: Add list of extcaps to about dialog
Adds the list of available extcaps to the plugin list in the
About dialog of Wireshark (Qt only). To do this, and additional
sentence is provided in the extcap arguments list, which allows
for additional information to be passed (as of right now, just
version and display is used)

Additionally, cleans up the code when using g_free.

Bug: 11683
Change-Id: I04a958e2b73c9a707ab1cb4f2fc8345833a854a9
Reviewed-on: https://code.wireshark.org/review/13224
Petri-Dish: Roland Knall <rknall@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Stig Bjørlykke <stig@bjorlykke.org>
Reviewed-by: Roland Knall <rknall@gmail.com>
2016-01-15 11:30:39 +00:00
Guy Harris 8b7020597a Don't use g_list_free_full().
It first appeared in GLib 2.28, and we support - and use, in the 32-bit
OS X buildbot - earlier versions.

Change-Id: I941a0206507e532c31cb13a918e3eb4d081e6ea3
Reviewed-on: https://code.wireshark.org/review/13240
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-01-12 20:08:49 +00:00
Roland Knall 645516b041 extcap: Sort extcap interfaces alphabetically
The interface list is not sorted at all, leading to
a very chaotic list. This sorts it alphabetically, as
well as correct a type in extcap_init_interfaces.

Bug: 11998
Change-Id: Ib5381a1761e8f07f9ba7996b3e6276da063b3932
Reviewed-on: https://code.wireshark.org/review/13220
Petri-Dish: Roland Knall <rknall@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Roland Knall <rknall@gmail.com>
2016-01-12 11:07:35 +00:00
Roland Knall cfd5457ec0 extcap: Add regular expression validation support
Regular expressions follow the Qt Regex syntax, which is
 formulated after the Perl Regex syntax. A more detailed
 overview of the possible rules can be found at:
 http://doc.qt.io/qt-4.8/qregexp.html

 If a required option is present, even the double-click on
 the interface will first start the options dialog (Qt only)

 Required fields are marked bold and put first in the dialog.
 Additionally if validation failes (which it will if a required
 field is kept empty, but also if a non-required textfield is
 violating the defined regex), the label of the field is marked
 with red.

Change-Id: If04a1146d0dfa778332ab2a39122c7a6ee1e93d2
Reviewed-on: https://code.wireshark.org/review/12914
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>
2016-01-05 14:41:12 +00:00
Peter Wu 7046b4b084 extcap: plug some memleaks
The working directory for g_spawn_sync should not be escaped, it is
simply passed to chdir. The escaping was needed for the command, so do
so (hmm... maybe the argv arguments should be escaped too for Windows).

Also remove an unnecessary NULL command argument for extcap_foreach.

Note: there is still a memleak when exiting because the ifaces table is
not cleared after querying the list.

Change-Id: I1251d623b954a81848044b6d1faf8dcec8ce465b
Reviewed-on: https://code.wireshark.org/review/12530
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>
2015-12-19 23:23:59 +00:00
Pascal Quantin 9ba4c95b55 extcap: fix a crash introduced in g622603b
When using GTK UI, cfilter is initialized to NULL, not to an empty string.

Change-Id: Ic9f3957d4de551a929578e76d5b9c63936517299
Reviewed-on: https://code.wireshark.org/review/11910
Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
2015-11-17 10:37:36 +00:00
Dario Lombardo 622603b277 extcap: fix a bug in cfilter
When no filter is specified, interface_opts.cfilter is not null but an empty string.

Change-Id: I5755ab7dd840be28334768cf26999048441fcc4e
Reviewed-on: https://code.wireshark.org/review/11907
Reviewed-by: Stig Bjørlykke <stig@bjorlykke.org>
2015-11-17 08:25:35 +00:00
Stig Bjørlykke 9c0d550a4a extcap: Provide capture filter to extcap binary
Added the option --extcap-capture-filter to extcap to send the capture filter
from the main screen to the extcap binary.

Change-Id: I75f0d7dbec810551225377f9221053298488cdd5
Reviewed-on: https://code.wireshark.org/review/11423
Reviewed-by: Roland Knall <rknall@gmail.com>
Reviewed-by: Stig Bjørlykke <stig@bjorlykke.org>
2015-11-05 07:42:35 +00:00
Dario Lombardo 23beb9700c extcap: fix a bug in create_tempfile() return check (CID 1323930)
Change-Id: Ifacdfee5c12e676969cfe536dfeda2be93426a46
Reviewed-on: https://code.wireshark.org/review/10929
Reviewed-by: Michal Labedzki <michal.labedzki@tieto.com>
Petri-Dish: Michal Labedzki <michal.labedzki@tieto.com>
Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
2015-10-12 13:56:32 +00:00
Guy Harris 32e785f813 The official #define for 32-bit and 64-bit Windows is _WIN32.
It's _WIN32, with a leading underscore, not WIN32.  See, for example:

    https://sourceforge.net/p/predef/wiki/OperatingSystems/

and

    https://msdn.microsoft.com/en-us/library/b0084kay.aspx

*Some* environments may also define WIN32, but we shouldn't depend on
that.

Replace all-caps "WIN32" referring to Windows in comments and other text
with "Windows" or "Win32".  (The two are pretty much equivalent, these
days; nobody much cares about Win16, not that we ever ran on it, and
64-bit Windows is just a 64-bitified Win32.)

Change-Id: Id327bcd4b1e9baa4f27055eff08c2d9e594d6f70
Reviewed-on: https://code.wireshark.org/review/10367
Petri-Dish: Guy Harris <guy@alum.mit.edu>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2015-09-02 22:59:10 +00:00
Roland Knall 5727ebe689 extcap: Implement QT extcap options
Implementing a button in the interface list, to bring up
 the extcap options dialog, as well as a dialog, which will
 be generated depending on the selected extcap options.

Change-Id: I1733dc6a8c1a121089a9c353aff10bc4a53e86de
Reviewed-on: https://code.wireshark.org/review/8224
Petri-Dish: Michal Labedzki <michal.labedzki@tieto.com>
Reviewed-by: Roland Knall <rknall@gmail.com>
Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
2015-05-05 09:35:10 +00:00
Alexis La Goutte 32bbe0af23 Extcap: fix logically dead code (CID 1232344)
Change-Id: Ia6c178a9a5ec413004107f63c8dcaa38c19690b9
Reviewed-on: https://code.wireshark.org/review/8096
Petri-Dish: Alexis La Goutte <alexis.lagoutte@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Evan Huus <eapache@gmail.com>
2015-04-16 22:40:02 +00:00
Gerald Combs 40ce324f4d Set the extcap working directory on Windows.
On Windows, prepend the main program directory to %Path% when spawning
extcap processes. This lets us place androiddump in extcap while allowing
it to locate its DLLs.

Change-Id: I406c47ce71323266d5f14fb596931398464e452d
Reviewed-on: https://code.wireshark.org/review/8057
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: Gerald Combs <gerald@wireshark.org>
2015-04-15 20:26:13 +00:00
Pascal Quantin 2e8d8e12cd dumpcap: fix opening of pipes on Windows broken since gbed29af
Previous code was assuming that all local pipes were of extcap type. Let's explicitly check for extcap prefix now.

Bug: 10803
Change-Id: If955e77a9ee2af11b553740269964c40273d5177
Reviewed-on: https://code.wireshark.org/review/8013
Petri-Dish: Pascal Quantin <pascal.quantin@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
2015-04-13 17:43:40 +00:00
Pascal Quantin 606fa969ba Extcap: fix USBPcap capture broken by g8204578
g8204578 was not the right way to do things: if_type is used to identify an extcap interface

Change-Id: Iead6c5e63f6874012c27ed7c1bf7152a5891ad65
Reviewed-on: https://code.wireshark.org/review/7849
Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
2015-03-29 17:48:28 +00:00
Pascal Quantin 8204578251 Extcap: display a USB icon when adding a USBPcap interface
Change-Id: Ibe78b115eb6e7e737a5dc9c8a7937b82d8cf76a8
Reviewed-on: https://code.wireshark.org/review/7830
Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
2015-03-27 16:56:41 +00:00
Evan Huus 8fb74b4a68 extcap: remove use of g_list_free_full
It requires a newer glib than we support

Change-Id: Id8f14d4188a9ba55e0a5196bb877e2fe6a0c8d3f
Reviewed-on: https://code.wireshark.org/review/4652
Reviewed-by: Evan Huus <eapache@gmail.com>
2014-10-13 16:09:47 +00:00
Tomasz Moń eed22acbcf Fix double free.
This double free involves damaging GHashTable internals (key and value).

Change-Id: I17c8a473b96ab28e611ccf79ddd2b3da56512184
Reviewed-on: https://code.wireshark.org/review/4629
Tested-by: Pascal Quantin <pascal.quantin@gmail.com>
Reviewed-by: Tomasz Moń <desowin@gmail.com>
Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
2014-10-12 20:22:53 +00:00
Tomasz Moń fc2f31810a Fix handling of extcap boolflags which defaults to true.
Example:
arg {number=0}{call=--test}{type=boolflag}{default=true}

Before this change --test was never added to argument list (no matter if
user left it selected or explicitly deselected it).

After this change --test will be added to argument list unless user
explicitly deselects it.

Change-Id: Ia5bc11f900b03e630aba882ef918dcb7f0b79291
Reviewed-on: https://code.wireshark.org/review/4618
Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
Tested-by: Pascal Quantin <pascal.quantin@gmail.com>
2014-10-12 19:54:57 +00:00
Tomasz Moń 5c0a3beee2 Remove redundant and erroneous debug log message.
Change-Id: I91d6131b3b4b7ef670f0d188ebd6da3947c49bdc
Reviewed-on: https://code.wireshark.org/review/4548
Reviewed-by: Michael Mann <mmann78@netscape.net>
2014-10-08 18:11:37 +00:00
Bill Meier 5051ae1cbe Convert "4 space tabs" to spaces; Adjust editor modelines.
Change-Id: I8d61d959c79e6aa9875c58680c54a331d18079cc
Reviewed-on: https://code.wireshark.org/review/4504
Reviewed-by: Bill Meier <wmeier@newsguy.com>
2014-10-06 18:29:40 +00:00
Tomasz Moń 20795925ff Update capture_opts in extcap_cleanup().
This fixes redundant extcap_pid handle close that could occur in
capture_opts_del_iface() which resulted in unhandled exception on
Windows.

Change-Id: I06b680fcb65cd6fd854a25fb1b01248dce3251a1
Reviewed-on: https://code.wireshark.org/review/4447
Petri-Dish: Alexis La Goutte <alexis.lagoutte@gmail.com>
Reviewed-by: Roland Knall <rknall@gmail.com>
Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
2014-10-04 11:17:01 +00:00
Tomasz Moń 06926aed88 Wait for extcap to connect to pipe on Windows.
This prevents dumpcap from failing with timeout exceeded error message
with some extcaps (especially those that display UAC screen) by making
sure that extcap connects to pipe before dumpcap is even started.

Change-Id: I549da9217c7f4ae89509330ca4fa613a119a9523
Reviewed-on: https://code.wireshark.org/review/4428
Petri-Dish: Alexis La Goutte <alexis.lagoutte@gmail.com>
Reviewed-by: Roland Knall <rknall@gmail.com>
Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
2014-10-04 11:12:08 +00:00
Tomasz Moń a6988b451f Fix memory leak and heap corruption on Windows.
LPSECURITY_ATTRIBUTES is type definition for pointer to SECURITY_ATTRIBUTES
structure.

Change-Id: I94a835bfd8f7eb76c808fac8286ca3f2db9b19c3
Reviewed-on: https://code.wireshark.org/review/4449
Reviewed-by: Michael Mann <mmann78@netscape.net>
Petri-Dish: Michael Mann <mmann78@netscape.net>
Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
2014-10-03 20:29:12 +00:00
Pascal Quantin e28f490426 Extcap: restore compatibility with GLib 2.16.0
While we are at it, fix what seem to be a memory leak in extcaps_init_initerfaces()

Change-Id: I1bb9a1b44d16f986eedd192b15cce84c5881a917
Reviewed-on: https://code.wireshark.org/review/3820
Reviewed-by: Roland Knall <rknall@gmail.com>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
2014-08-26 14:57:09 +00:00
Graham Bloice 97546165fa Modify includes of config.h so that out-of-tree builds, i.e. CMake
don't pick up the in-tree copy.

Change-Id: I7ec473876cdba1a025c52362d7f6adc62d24ce71
Reviewed-on: https://code.wireshark.org/review/3798
Petri-Dish: Graham Bloice <graham.bloice@trihedral.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Roland Knall <rknall@gmail.com>
Reviewed-by: Graham Bloice <graham.bloice@trihedral.com>
2014-08-24 08:04:08 +00:00
Roland Knall bed29af46d Extcap Capture Interface
Extcap is a plugin interface, which allows for the usage
 of external capture interfaces via pipes using a predefined
 configuration language which results in a graphical gui.

 This implementation seeks for a generic implementation,
 which results in a seamless integration with the current
 system, and does add all external interfaces as simple
 interfaces.

 Windows Note: Due to limitations with GTK and Windows,
 a gspawn-winXX-helper.exe, respective gspawn-winXX-helper-console.exe
 is needed, which is part of any GTK windows installation.

 The default installation directory from the build is an extcap
 subdirectory underneath the run directory. The folder used by
 extcap may be viewed in the folders tab of the about dialog.

 The default installation directory for extcap plugins with
 a pre-build or installer version of wireshark is the extcap
 subdirectory underneath the main wireshark directory.

 For more information see:

  http://youtu.be/Nn84T506SwU
  bug #9009

 Also take a look in doc/extcap_example.py for a Python-example
 and in extcap.pod for the arguments grammer.

 Todo:
   - Integrate with Qt - currently no GUI is generated, but
     the interfaces are still usable

Change-Id: I4f1239b2f1ebd8b2969f73af137915f5be1ce50f
Signed-off-by: Mike Ryan <mikeryan+wireshark@lacklustre.net>
Signed-off-by: Mike Kershaw <dragorn@kismetwireless.net>
Signed-off-by: Roland Knall <rknall@gmail.com>
Reviewed-on: https://code.wireshark.org/review/359
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2014-08-21 03:34:02 +00:00