Commit Graph

1251 Commits

Author SHA1 Message Date
Guy Harris 6014d7ad2b cpuid: clean up, update. and expand some comments. 2022-06-01 00:42:47 -07:00
Guy Harris 02eb128bef cpuid: don't use __cpuid on non-x86 Windows.
We aren't *yet* building ARM64 Wireshark for Windows, but throw in a bit
of future-proofing.  (I guess nobody ever built it for Itanium.)
2022-06-01 00:07:59 -07:00
Roland Knall 28b917a72e extcap: Close pipe on windows properly
Windows implements so called CRT handlers, which will catch any
assertions happening inside so called crt routines and either
displays a debug dialog (Cancel, Retry, Ignore) or outright crashes
the application.

See
https://docs.microsoft.com/en-us/cpp/c-runtime-library/parameter-validation?view=msvc-170
for an explanation of the behaviour.

Now, in the current situation here, close will detect (correctly)
that the pipe it is supposed to be closing is already closed. This
happens (again correctly) because it had been closed by the extcap
application.

The change added, checks for a closed pipe first, and if so just
returns -1 (as it should) silently without calling the CRT routine,
therefore not crashing
2022-05-16 14:48:37 +02:00
Gerald Combs 70bd130379 Fix "generated by" comments in configuration files.
Add get_configuration_namespace() and use it in code that writes
"generated by" comments at the top of various configuration files.

Update our Logwolf colorfilters.
2022-04-29 18:00:21 +00:00
John Thacker 2dd07bc5b9 glib: Bump required version to 2.50
All the currently supported distributions have at least 2.50.
Remove a version check.
2022-04-22 12:55:37 +00:00
John Thacker 45da161430 libgcrypt: Remove HAVE_GCRYPT_AEAD , _CHACHA20
Libgcrypt 1.8.0 is required now, so these are always defined.
2022-04-21 07:11:32 -04:00
John Thacker b80cdaa243 libgcrypt: Require version 1.8.0
Libgcrypt 1.8.x is required for a large amount of decryption
support and is the current LTS version of libgcrypt. The 1.6 and
1.7 series have been end-of-life since 2017-06-30 and 2019-06-30,
respectively.

The Linux distributions that have versions of libgcrypt before 1.8.0
are nearing or at end of support (RHEL7, SLES 12, Debian stretch,
Ubuntu 16.04LTS) and can be supported by the Wireshark 3.6 LTS release
series.

Remove an enormous amount of ifdefs based on libgcrypt versions
1.6.0, 1.7.0, and 1.8.0. There will be a second pass for the
commons defines HAVE_LIBGCRYPT_AEAD, HAVE_LIBGCRYPT_CHACHA20, and
HAVE_LIBGCRYPT_CHACHA20_POLY1305, which are now always defined.

The ISAKMP dissector has some comments noting that some workarounds
were used for libgcrypt 1.6 that aren't needed with 1.7; perhaps
that could be updated now.
2022-04-20 21:30:21 -04:00
Gerald Combs 69b9c480fd Revert "wsutil: Use a separate "extlog" directory for Logwolf extcaps."
This reverts commit 54553de59d.

As noted in !6694, it would probably make more sense to handle this a
different way.
2022-04-18 16:46:20 -07:00
João Valverde 09696f1762 Try to fix a narrowing warning
"C:\Development\wsbuild64\Wireshark.sln" (default target) (1) ->
"C:\Development\wsbuild64\epan\dfilter\dfilter.vcxproj.metaproj" (default target) (18) ->
"C:\Development\wsbuild64\epan\dfilter\dfilter.vcxproj" (default target) (108) ->
       (ClCompile target) ->
C:/Development/wireshark/epan/dfilter/scanner.l(463,54): warning C4267: '+=': conversion from 'size_t' to 'int
       ', possible loss of data [C:\Development\wsbuild64\epan\dfilter\dfilter.vcxproj]
C:/Development/wireshark/epan/dfilter/scanner.l(463,54): warning C4267:         state->location.col_start += sta
       te->location.col_len; [C:\Development\wsbuild64\epan\dfilter\dfilter.vcxproj]
C:/Development/wireshark/epan/dfilter/scanner.l(463,54): warning C4267:
                           ^ (compiling source file C:\Development\wsbuild64\epan\dfilter\scanner.c) [C:\Development\ws
       build64\epan\dfilter\dfilter.vcxproj]
2022-04-11 22:23:13 +01:00
João Valverde 24443fa33a tshark: Add underline to dfilter errors
$ tshark -Y 'frame.number == 123foobar and ip' -r /dev/null
tshark: "123foobar" is not a valid number.
    frame.number == 123foobar and ip
                    ^~~~~~~~~
2022-04-11 19:25:37 +00:00
Gerald Combs 54553de59d wsutil: Use a separate "extlog" directory for Logwolf extcaps.
If we're running in the Logwolf configuration namespace, look for
extcaps in a directory named "extlog". This paves the way for adding
log-specific capture utilities.
2022-04-07 21:41:36 +00:00
Gerald Combs 798136f107 wsutil: Use the correct variable.
Check our configuration namespace, not its name.
2022-04-05 12:16:22 -07:00
Gerald Combs 3086774fa6 wsutil: Add configuration namespaces.
Rename init_progfile_dir to configuration_init. Add an argument which
specifies our configuration namespace, which can be "Wireshark"
(default) or "Logwolf".
2022-04-04 09:39:27 -07:00
João Valverde d54e22b872 safe-math: Remove unnecessary clutter 2022-03-31 15:49:43 +01:00
João Valverde e15658d1c0 safe-math: Fix non-existent built-ins
Divison and modulo are not built-ins implemented by GCC or Clang.

Replace the spurious macro definition with the internal implementation.
2022-03-31 15:49:43 +01:00
João Valverde 2a9cb588aa dfilter: Add binary arithmetic (add/subtract)
Add support for display filter binary addition and subtraction.

The grammar is intentionally kept simple for now. The use case
is to add a constant to a protocol field, or (maybe) add two
fields in an expression.

We use signed arithmetic with unsigned numbers, checking for
overflow and casting where necessary to do the conversion.
We could legitimately opt to use traditional modular arithmetic
instead (like C) and if it turns out that that is more useful for
some reason we may want to in the future.

Fixes #15504.
2022-03-31 11:27:34 +01:00
João Valverde 18a2a6827f wslog: Refactor ws_log_set_fatal() for consistency 2022-03-26 00:15:50 +00:00
Jeff Morriss 80d0283341 mpeg: handle the presence of an image in the ID3v2 header.
Fixes #17985.
2022-03-10 07:38:14 +00:00
Gerald Combs e482b375f2 Rename the "image" directory to "resources".
The "image" directory contains resource compiler assets and other
application resources, so name it "resources."
2022-03-09 02:07:51 +00:00
Huang Qiangxiong 8a9cb14aec json_dumper: Adding support to dump JSON to GString 2022-03-03 14:47:32 +00:00
João Valverde ac6cbbcda3 Windows: Fix build
For some reason this was not caught by the CI.
2022-02-24 20:29:04 +00:00
David Perry e2fab18853 wsutil: New API to gather compile/runtime info 2022-02-24 13:27:08 +00:00
David Perry 1e0d117eb7 Specify directory for temporary captures 2022-02-09 14:32:28 +00:00
John Thacker 044dd69725 wsutil: Just use g_utf8_validate for now
g_utf8_validate_len doesn't exist until glib 2.60, so just
use g_utf8_validate.  It does the same thing when the length parameter
is unsigned. Fixes CentOS 7.
2022-02-05 22:34:21 -05:00
John Thacker 25d0c88251 epan: Add BASE_SHOW_UTF_8_PRINTABLE
Add BASE_SHOW_UTF_8_PRINTABLE and related function tvb_utf_8_isprint
for supporting fields of bytes that are "maybe UTF-8" (default or
SHOULD be UTF-8 but could be something else, with no encoding indicator),
such as SSID fields in IEEE 802.11 (See #16208), certain OctetString
fields in Diameter or PFCP, and other places where
BASE_SHOW_ASCII_PRINTABLE is currently used. Fix #5307
2022-02-06 00:32:13 +00:00
Paul Koning 6231bdc716 Fix Linux build issue
This fixes an error due to memcpy not being declared.  Closes #17911.
2022-01-27 04:43:52 +00:00
João Valverde 7afb52c479 ws_assert: refactor assertions 2022-01-05 13:31:53 +00:00
João Valverde 1dfba751e5 wslog: Replace ws_assert() 2022-01-05 13:31:52 +00:00
João Valverde f7b904f328 wslog: Convert to C99/POSIX types 2022-01-05 13:31:52 +00:00
João Valverde 947c617812 Remove some circular dependencies on wireshark.h 2022-01-05 13:31:52 +00:00
João Valverde 232628322c wslog: Rewrite macros 2022-01-05 13:31:52 +00:00
João Valverde 3f27a830fc wslog: Use a wider type for line 2022-01-05 13:31:52 +00:00
Guy Harris 0e98eb412f nstime: "localtime()" is an API, "local time" is local time. 2022-01-03 23:08:07 +00:00
Stig Bjørlykke d8474fdee7 Happy New Year 2022 2022-01-01 14:08:38 +01:00
John Thacker 156a958d3f wsutil: Fix time zone handling.
Time zone handling was reversed, partially due to the tests having
it backwards.
2021-12-30 21:20:08 +00:00
João Valverde 60533a55ff wslog: Add WS_DEBUG_HERE() macro
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.
2021-12-29 15:21:46 +00:00
João Valverde 7e041118d8 epan: Add back ABSOLUTE_TIME_NTP_UTC representation
It is a special case the prints "NULL" if time is zero.
2021-12-29 00:30:17 +00:00
João Valverde da790dd7bf wsutil/nstime: Fix ISO8601 parsing with tz offset separator
The format "23:59:59+2000" is valid but the code assumes that
if the date/time format uses separators, the timezone offset
must have them too. Fix that. Add test cases for timezone
offsets +HHMM and +HH.
2021-12-27 23:44:58 +00:00
João Valverde 737a76f6c9 wsutil/nstime: Add tests for iso8601_to_nstime() 2021-12-27 23:44:58 +00:00
João Valverde 48bb9534d7 wsutil/inet_addr: Add a cast to squelch a narrowing warning 2021-12-27 23:11:51 +00:00
João Valverde 14a1dfbe10 wsutil/inet_addr: Refactor to use C99/POSIX types
Rewrite ws_inet_pton{4,6} and ws_inet_ntop{4,6} without
GLib types.

Check for strerrorname_np() and use that is available,
to simplify error handling.

Add some minimal tests.
2021-12-27 19:02:50 +00:00
João Valverde 0d5bfd44a8 Use a wrapper function to call strptime()
Encapsulate the feature requirements for strptime() in a
portability wrapper.

Use _GNU_SOURCE to expose strptime. It should be enough on glibc
without the side-effect of selecting a particular SUS version,
which we don't need and might hide other definitions.
2021-12-27 14:07:32 +00:00
John Thacker b1b1d24548 wsutil: Declare ws_inet_* with extern "C"
Specify C linkage for ws_inet_pton[4|6] in order to use them
from the GUI.
2021-12-27 01:02:02 -05:00
Moshe Kaplan 69d54d6f8e Corrects repeated words throughout the code.
Repeated words were found with:
egrep "(\b[a-zA-Z]+) +\1\b" . -Ir
and then manually reviewed.
Non-displayed strings (e.g., in comments)
were also corrected, to ease future review.
2021-12-22 11:01:11 +00:00
João Valverde 15565c2b25 Fixup -Wshorten-64-to-32 warnings with Clang
On Windows the POSIX read() and write() don't use the C99/POSIX
types size_t and ssize_t so we must do the same to avoid
gymnastics to squelch narrowing warnings.

This adds two types for that purpose that have the correct
definition for both Windows and POSIX.
2021-12-21 10:29:45 +00:00
João Valverde 4448b6494e Add a ws_posix_compat.h header
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.
2021-12-21 01:30:06 +00:00
João Valverde 36d5aad962 wsutil: Split ws_regex_matches() into two functions
Split ws_regex_matches() into two functions with better semantics
and remove the WS_REGEX_ZERO_TERMINATED symbol.

ws_regex_matches() matches zero terminated strings.

ws_regex_matches_length() matches a string length in code units.
2021-12-21 00:40:02 +00:00
João Valverde fe5248717f Replace g_snprintf() with snprintf()
Use macros from inttypes.h with format strings.
2021-12-19 20:06:13 +00:00
João Valverde 737d1dc125 Add missing header, fix macOS build 2021-12-19 19:09:05 +00:00
João Valverde 7160b4b177 wsutil: Use snprintf() and ws_strdup_printf()
Replace GLib I/O with C library I/O.
2021-12-19 12:23:14 +00:00