The folder structure was introduced to organize the
plugins and permit more efficient loading during the
startup but the gains are slight and the requirement
is awkward to describe and easy to forget in practice.
Remove that requirement and load any compatible binary
plugin in the plugin folder. This also allows extra
flexibility to organize the plugins in categories,
for example adding an "external" folder for plugins
external to the project, or whatever else one might
wish.
To check for library compatibility we add an extra string
signature token in the plugin that can be compared with
the expected plugin type.
The downside is that the initialization is still performed
3 times and more files need to be skipped now but in practice
this should not have a measurable performance impact
and this eliminates a class of annoying small forgetful mistakes
when manually installing files.
This is still compatible with the old requirement of having a
epan/wiretap/codecs subfolder. At most one sublevel is allowed
to minimize security risks and slowness with any random folder
hierarchies if the plugins folder setting is somehow misconfigured
or hijacked.
Ping #19389.
Don't do so only if no interfaces are reported; we now append extcaps to
the list even if, due to an error, no interfaces were found, so report
an error in that cas regardless of whether the interface list is empty
or not.
Add additional exit status values for -D errors (and potentially for
errors elsewhere), use them, and allow "pcap error" in the tests
for -D.
This adds a dialog in the Tools menu to open a console and evaluate
Lua code using the embedded Lua engine. It replaces the previous
console.lua implementation that was more limited to use, because
it relies on GUI bits exposed to Lua. It used two separate windows
for that reason.
The implementation uses the existing "funnel" API amd relies heavily
on callbacks to maintain separation between GUI and epan code and
make it generic enough to possibly support more use cases than just
the Lua 5.2 console.
The open and close callbacks are used to install and remove a custom
print() lua function with dialog creation and destruction.
The eval callback is basically the same as luaL_dostring().
Downgrade the severity of this issue. Even though it is critical
in the sense that it is a (recoverable) programming error, by
breaking the contract for the function arguments, for practical
purposes we don't want to constantly trip our fuzzers with this
issue (running with a fatal critical level) so downgrade the
ws_return.h severity to "info".
At the same time use a dedicated log domain to the debugging
purpose can be fulfilled by setting the "InvalidArg" domain
as fatal.
Remove the duplicated function name from the output while at it.
The current logging, if enabled, does an extra strdup and
double prints the functions and line number.
Note these are optimized away on a Release build target.
Dumpcap depends on wsutil.so. The path to the shared library
is encoded in the RPATH (or RUNPATH) property of ELF binaries.
This is currently an absolute path on most Unixy systems.
Dumpcap could not be made to work with a relative RPATH because it
uses elevated privileges and some loaders will ignore relative
RPATHs and non-standard paths under those circumstances, because of
(justified) security concerns.
To enable relocation of the program we link dumpcap statically
with wsutil instead.
This provides a fully working relocatable installation on Linux
and other platforms that support relative RPATHs.
- ws_assert does not work, because _ASSERT_ENABLED is false and gets optimized
- add _U_ to unused variables because of compile flag /W3
- local variables need suppression of warning 4189
Rename flex macros using parenthesis (mostly a style issue):
DIAG_OFF_FLEX -> DIAG_OFF_FLEX()
DIAG_ON_FLEX -> DIAG_ON_FLEX()
Use the same kind of construct with lemon generated code using
DIAG_OFF_LEMON() and DIAG_ON_LEMON(). Use %include and %code
directives to enforce the desired order with generated code
in the middle in between pragmas.
Fix a clang-specific pragma to use DIAG_OFF_CLANG().
DIAG_OFF(unreachable-code) -> DIAG_OFF_CLANG(unreachable-code).
Apparently GCC is ignoring the -Wunreachable flag, that's why
it did not trigger an unknown pragma warning. From [1}:
The -Wunreachable-code has been removed, because it was unstable: it
relied on the optimizer, and so different versions of gcc would warn
about different code. The compiler still accepts and ignores the
command line option so that existing Makefiles are not broken. In some
future release the option will be removed entirely. - Ian
[1] https://gcc.gnu.org/legacy-ml/gcc-help/2011-05/msg00360.html
Add UNICODE_REPLACEMENT_CHARACTER as a #define for the Unicode
REPLACEMENT CHARACTER code point (0x00FFFD), and use that instead of
0xfffd/0xFFFD/0x00FFFD in cases where that value refers to REPLACEMENT
CHARACTER.
This removes the last dependency of the logging subsystem on the
preferences module. The latter is started much later than the former
and this is an issue.
The Windows-only preference "gui.console_open" is stored in the
registry as HKEY_LOCAL_USER\Software\Wireshark\ConsoleOpen. The semantics
are exactly the same. The preference is read by the logging subsystem
for initialization and then again by the preferences (read/write) so
the user can configure it as before.
The code to store the preference also in the preferences file was
kept, for backward compatibility and because it is not incompatible
with using the Registry concurrently.
The elimination of the prefs dependency also allows moving the Windows
console logic to wsutil and add the functionality to wslog directly,
thereby eliminating the superfluous Wireshark/Logray custom log handler.
To be able to read the ws_log_console_open global variable from
libwireshark it becomes necessary to add a new export macro
symbol called WSUTIL_EXPORT.
This adds a new attribute that allows declaring Wireshark
functions as deprecated.
Also disabe -Werror with deprecated declarations Deprecated
declarations can be introduced suddenly with a new version
of an external dependency or a new internal deprecation and
that has its own timeline to fix. We should still be able to
build with -Werror in that case.
This enable the warning at "warning" level (neither ignored nor
an error). This is used to selectively disable -Werror for a section
of code but keep the warning enabled as useful and relevant.
For example it can be used to defer replacing deprecated declarations
and still build with -Werror enabled globally.
Using a warning is probably too exalted for the current state
of the code, where UTF-8 errors are somewhat expected from
dissectors that are lax about input validation.
Use a debug level with its own "UTF-8" domain instead.
Using a dedicated domain allows to filter on encoding errors and
with some enhancements to the logging subsystem make them fatal
for tracking and debugging purposes.
Using a dedicated domain might have other drawbacks but for now
it seems like the best approach.
This prevents the weird failures I saw on macOS in #17856; instead, it
should fail on *all* platforms with
Unhandled exception ("epan/proto.c:8800: failed assertion "DISSECTOR_ASSERT_NOT_REACHED"", group=1, code=6)
(which it does on macOS 11.6/Xcode 12.5.1 and Windows 10/VS 2019
16.11.8; according to
https://en.wikipedia.org/w/index.php?title=Thread-local_storage&oldid=1064900318#C_and_C++
the major UN*X C compilers support __thread and the major Windows C
compilers support __declspec(thread).).
@jvalverde: on branches that require C11/C++11 support, we could perhaps
just use _Thread_local for C and thread_local for C++. Note that
<thread.h> is optional in C11, and macOS 11.6/Xcode 12.5.1 does not
appear to include it.)
This does not *fix* the aforementioned issue; to do *that* we need to do
TRY in the register-dissectors thread code. I'm committing this
separately because it fixes a bug in our exception package that could
cause all sorts of randomness now and in the future - what we're doing
now is Just Wrong.
(Yes, there's code to support per-thread exception handler stacks *on
platforms with pthreads*, but this is simpler *and* also works on
Windows.)
Add a LOG_LEVEL_ECHO that is always active and always non-fatal.
Use that to implement a WS_DEBUG_HERE() macro for quick print outs
during debugging sessions.
Currently used to define ssize_t on platforms that lack it.
Fix some Windows build errors caused by moving the definition into a
separate header.
Fix some narrowing warnings on Windows x64 from changing the definition
of ssize_t from long int to int64_t.
The casts in dumpcap are ugly but necessary. The whole code needs
to be rewritten for portability, or the warnings disabled.
Wmem is an alternative to GLib data structures so it should
have the same scope and be equally as convenient to use.
Wmem does not and cannot depend on anything else other than
GLib.
Blind attempt to fix Debian package brokenness managing
headers separately from install rules.
Global public headers that don't fit any of the Wireshark
libraries should be placed in include/.
Eventually the C files in the root dir should be placed somewhere
else as well (like src/) but this is not a priority.
Fixes#17726.