Commit Graph

58 Commits

Author SHA1 Message Date
João Valverde 59c082c046 Add new global header wireshark.h with guideline
Remove ws_diag_control.h from config.h because that was a workaround
for the lack of a public global header. Fix the resultant build errors.
2021-10-22 06:41:44 +00:00
João Valverde 39df3ae3c0 Replace g_log() calls with ws_log() 2021-06-16 12:50:27 +00:00
João Valverde 4aff36d501 Replace g_assert() with ws_assert() in places 2021-06-06 20:05:26 +00:00
João Valverde 9ba97d12d6 Add ws_debug() and use it
Replace most instances of ws_debug_printf() except in
epan/dissectors and dissector plugins.

Some replacements use printf(), some use ws_debug(), and
some were removed because they were dead or judged to be
temporary.
2021-05-24 01:13:19 +00:00
Moshe Kaplan e16166a74c Detect and replace bad allocation patterns
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-12-22 14:56:38 +00:00
Tomasz Moń 5f5a934bca Use g_hash_table_replace() when key depends on data
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>
2019-08-28 03:51:32 +00:00
Dario Lombardo f15cdcb1ea wsutil: improve plugins list output format.
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-17 05:21:55 +00:00
João Valverde 65d9c473f0 plugins: Minor interface improvement
Change the plugin compatibility check to make it more convenient to
define and check the major.minor Wireshark version.

Change-Id: I2a6d2a746682c29504311cce5c457e0a852c3daf
Reviewed-on: https://code.wireshark.org/review/29224
Petri-Dish: João Valverde <j@v6e.pt>
Tested-by: Petri Dish Buildbot
Reviewed-by: João Valverde <j@v6e.pt>
2018-08-21 19:56:12 +00:00
Guy Harris b1de8c87a1 Older versions of Clang don't understand -Wpedantic.
Define DIAG_OFF_PEDANTIC and DIAG_ON_PEDANTIC, and have it do nothing on
Clang prior to 4.0.

Change-Id: Ic6b2e607659db66f3210401024bf3f2239665506
Reviewed-on: https://code.wireshark.org/review/27649
Petri-Dish: Guy Harris <guy@alum.mit.edu>
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2018-05-18 22:31:05 +00:00
Peter Wu bb81e1807b Free g_ptr_array_free-related memory leaks
g_ptr_array_free(a, FALSE) returns "a->pdata". Callers that do not
handle this will leak memory (e.g. "tshark -G plugins"). Convert other
users to use the return value instead of direct access to "a->pdata".

Change-Id: I29835477d587f5f54bf0d94cdae9f375e3da3ce3
Reviewed-on: https://code.wireshark.org/review/27437
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
2018-05-14 13:42:10 +00:00
João Valverde 77543eb80c plugins: Remove autotools specific code for build path
Change-Id: I12a987cd84a7e04189a08771ce334e1d6152eab1
Reviewed-on: https://code.wireshark.org/review/27205
Petri-Dish: João Valverde <j@v6e.pt>
Tested-by: Petri Dish Buildbot
Reviewed-by: João Valverde <j@v6e.pt>
2018-04-30 11:15:28 +00:00
Guy Harris 8c959fcc35 Get rid of stuff that checks for a .libs directory.
.libs is a libtoolism, and we're not using autotools or libtool any
more, so there aren't any more libtoolisms.

Change-Id: Idc9ef37f9650197da096cc8e3cb3ed459b71dea0
Reviewed-on: https://code.wireshark.org/review/27137
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2018-04-25 03:47:35 +00:00
Guy Harris 5bf8da8a4c Fix casts.
A gconstpointer is a "pointer to const void", so it should be cast to
"pointer to const XXX".  A "pointer to const pointer to plugin" is a
"plugin *const *".

C's declaration syntax is not one of its strong points.  There's a
reason why the cdecl program, and the Web site that uses it,
http://cdecl.org, exists (as the tag line says, "C gibberish <->
English"), and why I used it to make sure I got this working.

Change-Id: Ia29bb25d17a1255a06b4ace542643c4b494d4977
Reviewed-on: https://code.wireshark.org/review/25835
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2018-02-17 18:41:23 +00:00
Dario Lombardo 8cd389e161 replace SPDX identifier GPL-2.0+ with GPL-2.0-or-later.
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-02-08 14:57:36 +00:00
João Valverde 38c0ffe4c6 Avoid #ifdef'ing out translation units
Change-Id: Ibef0120184ae577f11059fcaf0eaa24a32820273
Reviewed-on: https://code.wireshark.org/review/25502
Petri-Dish: João Valverde <j@v6e.pt>
Tested-by: Petri Dish Buildbot
Reviewed-by: João Valverde <j@v6e.pt>
2018-01-29 10:55:02 +00:00
João Valverde 66f85c65d5 plugins: Remove nordic_ble.dll exception
This should no longer be necessary with the sub-version directory
struture. If the user is installing a DLL for a built-in plugin, an
error message is appropriate.

Change-Id: I80842f1ea03a08594321a674650a1373aaa48712
Reviewed-on: https://code.wireshark.org/review/25500
Reviewed-by: João Valverde <j@v6e.pt>
2018-01-28 21:34:22 +00:00
João Valverde 5d1687e449 Rename plugins_scan_dir()
This makes it more obvious that it is a static function.

Change-Id: I7348c4326b1e388870cb6657d9c67bd1086357b0
Reviewed-on: https://code.wireshark.org/review/25499
Reviewed-by: João Valverde <j@v6e.pt>
2018-01-28 21:34:12 +00:00
João Valverde 285a0f5a96 Use g_str_has_suffix()
Change-Id: Ida335462efdfeef88a7afb3f27caf274632ca879
Reviewed-on: https://code.wireshark.org/review/25498
Reviewed-by: João Valverde <j@v6e.pt>
2018-01-28 21:34:05 +00:00
João Valverde 15d9ab22c3 plugins: Use per-library data structures
This is cleaner and allows the "duplicate plugin name check" to be
performed correctly (per module and not globally).

Change-Id: I2b2122495dc047af5b7043dcf020a525766b7c30
Reviewed-on: https://code.wireshark.org/review/25496
Petri-Dish: João Valverde <j@v6e.pt>
Tested-by: Petri Dish Buildbot
Reviewed-by: João Valverde <j@v6e.pt>
2018-01-28 17:56:05 +00:00
João Valverde 5352ef42f9 plugins: Add source tree subfolder for plugin library
This allows some simplification and makes things more consistent,
particularly for loading plugins from the build dir.

Also fixes the issue reported here:

https://www.wireshark.org/lists/wireshark-dev/201801/msg00061.html

Change-Id: I0d8a000ee679172bccad546a3b0c47a79486f44d
Reviewed-on: https://code.wireshark.org/review/25329
Petri-Dish: João Valverde <j@v6e.pt>
Reviewed-by: João Valverde <j@v6e.pt>
2018-01-16 08:51:37 +00:00
Guy Harris c721763858 Update a comment to reflect current reality.
All plugin types now have plugin_register() as the registration
function, so it's an entry point for the plugin registration function,
not the particular plugin type.

Clean up white space while we're at it.

Change-Id: I166359deac57512cb6e87b2c7388c4b25cc54e10
Reviewed-on: https://code.wireshark.org/review/25254
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2018-01-11 04:08:02 +00:00
Gerald Combs 5639b8014a Use an enum for plugin types.
Make plugins.c the source of truth for plugin names. Where plugins
reside and what they do are two different things, so split the plugin
directory and description into two separate elements.

CMake creates portable[1] builds on Windows and macOS. That is, the
build-time directory layout is the same as the installation directory
layout. Adjust various plugin paths macOS accordingly.

[1] You have to run osx-app.sh on macOS to prepare the application
bundle, but the goal is to create a directory/bundle that can be moved
or copied to a different system and run in the new location.

Change-Id: Icf9d02e61918fdf1404468baf52542910edf2743
Reviewed-on: https://code.wireshark.org/review/25166
Petri-Dish: Gerald Combs <gerald@wireshark.org>
Tested-by: Petri Dish Buildbot
Reviewed-by: Gerald Combs <gerald@wireshark.org>
2018-01-11 00:58:43 +00:00
João Valverde 995812c5f1 Refactor plugin registration and loading
Put different types of plugins (libwiretap, libwireshark) in different
subdirectories, give libwiretap and libwireshark init routines that
load the plugins, and have them scan the appropriate subdirectories
so that we don't even *try* to, for example, load libwireshark plugins
in programs that only use libwiretap.

Compiled plugins are stored in subfolders of the plugin folders, with
the subfolder name being the Wireshark minor version number (X.Y). There is
another hierarchical level for each Wireshark library (libwireshark, libwscodecs
and libwiretap).

The folder names are respectively plugins/X.Y/{epan,codecs,wiretap}.

Currently we only distribute "epan" (libwireshark) plugins.

Change-Id: I3438787a6f45820d64ba4ca91cbe3c8864708acb
Reviewed-on: https://code.wireshark.org/review/23983
Petri-Dish: João Valverde <j@v6e.pt>
Tested-by: Petri Dish Buildbot
Reviewed-by: João Valverde <j@v6e.pt>
2017-12-14 08:43:57 +00:00
Michael Mann 3d673da88c Convert to using use SPDX identifier on wsutil directory
Change-Id: Id73e641499e75bc1afc1dea29682418156f461fe
Reviewed-on: https://code.wireshark.org/review/24751
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot
Reviewed-by: Michael Mann <mmann78@netscape.net>
2017-12-10 04:36:29 +00:00
João Valverde 14e687c1dd Make plugin support a runtime property
Keep the option to disable at compile-time but use AC_ARG_ENABLE instead.

Change-Id: Ie8c3f5ba0db1eb6d9d4ffd742cd3aa049ead5007
Reviewed-on: https://code.wireshark.org/review/24026
Petri-Dish: João Valverde <j@v6e.pt>
Tested-by: Petri Dish Buildbot
Reviewed-by: João Valverde <j@v6e.pt>
2017-10-23 20:04:14 +00:00
João Valverde 2777003e12 Add version check for plugin compatibility
Only plugins built for the same feature release (X.Y) are assured binary
compatibility. Make sure we don't try to run unsuitable code and, if so,
warn the user. This might happen for example if the user manually copies
a binary plugin to the wrong folder, intentionally or by accident.

I'm using "release version" to loosely mean not a patch release
(i.e: a feature release).

Change-Id: I896e9cbbd2d3843623fff6af8ef51002ec06f1f8
Reviewed-on: https://code.wireshark.org/review/23807
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>
2017-10-03 10:09:24 +00:00
João Valverde 5c2a5dbdcd plugins: Improve output format
And some minor code style changes.

Change-Id: I97e53848db42c3981af69152b171b3a77f831da5
Reviewed-on: https://code.wireshark.org/review/23806
Reviewed-by: João Valverde <j@v6e.pt>
2017-10-01 21:13:45 +00:00
João Valverde 0e63979730 plugins: Move the build dir scanning code to a separate function
Change-Id: Iee476ac84d530810e5b70547c462050f1c03ee1b
Reviewed-on: https://code.wireshark.org/review/23755
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>
2017-09-26 20:56:03 +00:00
João Valverde a1969dd6f6 plugins: No need to allocate a new struct
Change-Id: Ic39cf1c7f199dc5e4879d954a649d21453dcc5e5
Reviewed-on: https://code.wireshark.org/review/23753
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>
2017-09-26 19:52:30 +00:00
João Valverde f2404376f8 plugins: Build the description string while loading
Change-Id: Ia67133c1c9d005fc4a81b0727a7b1849571ab29c
Reviewed-on: https://code.wireshark.org/review/23742
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>
2017-09-26 11:33:09 +00:00
João Valverde 0b76a4957d plugins: Sort the descriptions
Change-Id: I8113ba9782962856ce86475cddf40d69ed267fb4
Reviewed-on: https://code.wireshark.org/review/23733
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>
2017-09-26 09:50:14 +00:00
João Valverde f022a629f1 plugins: Use hash table for book-keeping
Avoid having to walk the list to check for existence on every file
load.

Now the binary plugin description list in About Wireshark is randomized
instead of sorted by load order. We may want to change that.

Add missing "const" to plugin->version.

Fix an apparent trivial leak where the GModule handle was not closed on
exit.

Change-Id: I774215a84b080bbe889f88cc6a9b777bcf60b335
Reviewed-on: https://code.wireshark.org/review/23732
Petri-Dish: João Valverde <j@v6e.pt>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2017-09-26 04:11:07 +00:00
João Valverde 8615081a09 plugins: Fix crash loading binary module twice
If a plugin is repeated we destroy the GModuleHandle in plugins_scan_dir()
but we have already added the entry points to the list of registered
plugins.

Check for repeated plugins before adding it to the list of registered
plugins, not after.

Don't check for both name and version, check only for repeated names.

Give the plugin callback a more descriptive name.

Change-Id: I22cbbb059b8029877580fc33517310496c93e5d5
Reviewed-on: https://code.wireshark.org/review/23726
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>
2017-09-25 16:45:23 +00:00
João Valverde 25ba538bc5 plugins: Be more descriptive in "about wireshark"->"folders"
Display separate entries for binary plugins and lua scripts.

This is explained in the user guide, that the binary folder is
a subfolder of the lua folder, but it's probably a good idea to be more
explicit about it, at the risk of cluttering the interface a bit.

Move GeoIP information down because it seems the least important.

Add helper functions to provide plugin version subdir.

Change some #ifdefs while at it for legibility.

Change-Id: Ieb8665df029b3c14de19e2c973bd9b1cc4ec4621
Reviewed-on: https://code.wireshark.org/review/23609
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>
2017-09-20 16:41:21 +00:00
João Valverde 8db4ddd40c Rename get_plugin_dir() for consistency
WS_DLL_PUBLIC const char *get_plugin_dir(void);
WS_DLL_PUBLIC const char *get_plugins_pers_dir(void);

Opt for the plural form consistently (for public functions at least).

Change-Id: I8a5861ad7f90f9c87168bd3275bd9dbc5c83b749
Reviewed-on: https://code.wireshark.org/review/23608
Petri-Dish: João Valverde <j@v6e.pt>
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-09-20 01:00:37 +00:00
João Valverde 9260461f4f plugins: Use minor version number for plugin install path
Wireshark patch releases (X.Y.Z) are binary compatible so reflect
that in the plugin installation path.

By installing to $pkglibdir/plugins/X.Y out-of-tree plugins don't
need to be reinstalled with every patch release.

Change-Id: I9d1728e6fb12bcb51d2a723af22c750cb7a966cf
Reviewed-on: https://code.wireshark.org/review/23497
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>
2017-09-17 16:55:51 +00:00
João Valverde 978f6b4e1a plugins: Fix paths to match WSUG
The Wireshark User Guide seems to say:

Global lua plugins are in $pkglibdir/plugins
Personal lua plugins are in XDG_CONFIG_HOME/plugins

Global binary plugins are in $pkglibdir/plugins/$version
Personal binary plugins are in XDG_CONFIG_HOME/plugins/$version

Fix code to match that. This is a backward-incompatible change
for global lua plugins and personal binary plugins.

Adds a version subfolder to the personal plugin folder for binary plugins.

This allows for safe upgrades and side-by-side installations
with different prefixes (they no longer use the same personal dir).

Change-Id: Ie0f039113628a257625a9a9fb2cb30e532f5dd47
Reviewed-on: https://code.wireshark.org/review/23516
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>
2017-09-17 16:54:52 +00:00
João Valverde 69f0cb0cef wsutil: Initialize and store plugin personal dir
Obviate allocation on every call to get_plugins_pers_dir().

Change-Id: I089ae499f93739d490d4552f59b5db5996f7d26f
Reviewed-on: https://code.wireshark.org/review/23495
Petri-Dish: João Valverde <j@v6e.pt>
Reviewed-by: Michael Mann <mmann78@netscape.net>
Reviewed-by: João Valverde <j@v6e.pt>
2017-09-11 16:48:49 +00:00
Guy Harris 2c44a7f930 Clean up handling of enabled/disabled protocols/heuristic dissectors.
Add a "report a warning message" routine to the "report_err" code in
libwsutil, and rename files and routines appropriately, as they don't
only handle errors any more.

Have a routine read_enabled_and_disabled_protos() that reads all the
files that enable or disable protocols or heuristic dissectors, enables
and disables them based on the contents of those files, and reports
errors itself (as warnings) using the new "report a warning message"
routine.  Fix that error reporting to report separately on the disabled
protocols, enabled protocols, and heuristic dissectors files.

Have a routine to set up the enabled and disabled protocols and
heuristic dissectors from the command-line arguments, so it's done the
same way in all programs.

If we try to enable or disable an unknown heuristic dissector via a
command-line argument, report an error.

Update a bunch of comments.

Update the name of disabled_protos_cleanup(), as it cleans up
information for disabled *and* enabled protocols and for heuristic
dissectors.

Support the command-line flags to enable and disable protocols and
heuristic dissectors in tfshark.

Change-Id: I9b8bd29947cccdf6dc34a0540b5509ef941391df
Reviewed-on: https://code.wireshark.org/review/20966
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-04-08 20:40:08 +00:00
Pascal Quantin cabd7d8293 wsutil: fix a NULL pointer dereference when there is a single plugin registered
Rework loop to avoid dereferencing a NULL pointer. Bug introduced in g6d79055

Change-Id: I88a9f2d045b633cc2365ff6ce939f3315e7d42cc
Reviewed-on: https://code.wireshark.org/review/20751
Reviewed-by: Michael Mann <mmann78@netscape.net>
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-03-28 05:05:13 +00:00
Dario Lombardo 2de30dd18d wsutil: fix bugs in plugins_cleanup().
If plugin_list was NULL, plugin_types didn't get cleaned.
Add test and set of open_info_arr.

Change-Id: I7669e3ba86039fb2b26ff2da64f51896053c5e68
Reviewed-on: https://code.wireshark.org/review/20195
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2017-02-26 18:00:23 +00:00
Dario Lombardo 64d0133e88 plugins: free list on cleanup.
Change-Id: Idff606297f72238f8539cb00ea394ee80fcb502c
Reviewed-on: https://code.wireshark.org/review/20074
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2017-02-18 14:13:26 +00:00
Dario Lombardo 6d79055ba6 wsutil: remove leaks from filesystem and plugins code.
Change-Id: Iac2805c0130bd2ba6cdb3c9dd997050274d58d99
Reviewed-on: https://code.wireshark.org/review/20020
Reviewed-by: Michael Mann <mmann78@netscape.net>
2017-02-18 13:45:14 +00:00
Stig Bjørlykke fc8f787565 Skip loading the Nordic BLE Sniffer dll on WIN32
The dissector for the Nordic BLE Sniffer was added as internal in
g7844a118, so ensure we don’t load this third party dll on WIN32.

Change-Id: I74c200d42793f3c1e764bc9f6c3a9a795d38a5a7
Reviewed-on: https://code.wireshark.org/review/19259
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>
2016-12-14 11:49:45 +00:00
Guy Harris 037c64aa34 Clean up initialization code for programs.
Make the init_progfile_dir() call unconditionally, even if plugins
aren't supported, as that doesn't necessarily mean nobody uses the
directory containing the executable.

Report the error the same way in all programs, and free the error string
after we're finished with it.

Make the error - and the comment before the code - reflect what
init_progfile_dir() is actually doing (the goal is to get the full
pathname of the directory *containing* the executable; that's generally
done by getting the pathname of the executable and stripping off the
name of the executable, but that's won't necessarily always be the
case).  Also note for TShark that we won't be able to capture traffic,
just as we do for Wireshark (if we don't have the pathname of the
program file, we don't have a pathname to use to find dumpcap).

Have the plugin scanner just fail silently if we weren't able to get the
plugin directory path, so we don't have to worry about calling it if
init_progfile_dir() fails.

Clean up white space while we're at it.

Change-Id: I8e580c719aab6fbf74a764bf6629962394fff7c8
Reviewed-on: https://code.wireshark.org/review/19076
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-12-05 04:27:49 +00:00
Guy Harris 295dbc609d Suppress another warning if told not to report failures.
That's another failure that can occur if you're trying to load a
libwireshark plugin in a program that doesn't use libwireshark if, for
example, references to an undefined symbol don't prevent the module from
being loaded in the first place.

Change-Id: I21629c0094fdca7dfbd88f39b7e6c10fb600b401
Reviewed-on: https://code.wireshark.org/review/17537
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-09-06 17:14:45 +00:00
Guy Harris 2a38dc74ed Have scan_plugins() take an argument specify what to do on load failures.
That's a less gross hack to suppress load failures due to not having
libwiretap than providing a no-op failure-message routine, as it at
least allows other code using a failure-message routine, such as
cmdarg_err() and routines that call it, to be used.

We really should put libwiretap and libwireshark plugins into separate
subdirectories of the plugin directories, and avoid even looking at
libwireshark plugins in programs that don't use libwireshark.

Change-Id: I0a6ec01ecb4e718ed36233cfaf638a317f839a73
Reviewed-on: https://code.wireshark.org/review/17506
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-09-05 23:27:02 +00:00
Michael Mann 1da1f945e2 Fix checkAPI.pl warnings about printf
Many of the complaints from checkAPI.pl for use of printf are when its embedded
in an #ifdef and checkAPI isn't smart enough to figure that out.
The other (non-ifdef) use is dumping internal structures (which is a type of
debug functionality)
Add a "ws_debug_printf" macro for printf to pacify the warnings.

Change-Id: I63610e1adbbaf2feffb4ec9d4f817247d833f7fd
Reviewed-on: https://code.wireshark.org/review/16623
Reviewed-by: Michael Mann <mmann78@netscape.net>
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>
2016-07-25 04:26:50 +00:00
Peter Wu 057b8d7dde plugins: do not import symbols globally
Clang's ASAN reported an ODR violation when plugins were loaded. Sure
enough, symbols did actually get loaded twice:

    ==5898==ERROR: AddressSanitizer: odr-violation (0x7fffd95a35e0):
      [1] size=7 'version' plugins/mate/plugin.c:19:31
      [2] size=6 'version' plugins/opcua/plugin.c:19:31

After this change, plugins cannot insert new symbols in the global
namespace.

Change-Id: Ib11f7263e9c586f8e7c1f8f5fb239b20d46ddd2f
Reviewed-on: https://code.wireshark.org/review/13260
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
Petri-Dish: Alexis La Goutte <alexis.lagoutte@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2016-01-31 13:31:28 +00:00
João Valverde b2b9b22fe9 Avoid breaking output string mid-sentence
Change-Id: I463f93e515ebe12ed30b1f08cca7d29a7bd535ae
Reviewed-on: https://code.wireshark.org/review/12552
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
Petri-Dish: Alexis La Goutte <alexis.lagoutte@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2015-12-12 13:54:13 +00:00