Commit Graph

3680 Commits

Author SHA1 Message Date
Guy Harris 109b92b5d7 wiretap: have wtap_dump_close() provide a "needs to be reloaded" indication.
This allows the "needs to be reloaded" indication to be set in the close
process, as is the case for ERF; having a routine that returns the value
of that indication is not useful if it gets seet in the close process,
as the handle for the wtap_dumper is no longer valid after
wtap_dump_close() finishes.

We also get rid of wtap_dump_get_needs_reload(), as callers should get
that information via the added argument to wtap_dump_close().

Fixes #17989.
2022-03-14 19:12:20 +00:00
Moshe Kaplan 23ed064ded wiretap: Fix doxygen comments
Add asterisks to doxygen generates for existing
supported_block_type comments.

Add < to #define's so that doxygen associates comments
with the #define above, instead of below.
2022-03-14 00:07:02 -04:00
Gerald Combs 87ff577257 Move Freedesktop files to resources/freedesktop. 2022-03-12 00:19:13 +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
Guy Harris 64d95a2808 pcap: fix the handling of the reserved field.
Don't commit to it being a "class" field.

Fix the bitfield for it.
2022-03-04 17:49:15 -08:00
Guy Harris e999b0a4d2 pcap: process the subfields of the link-layer-type-plus-stuff field.
Extract the FCS length information from that field, and reject captures
that have a non-zero "class" field (the 10-bit reserved field that was
once intended to allow other "classes" of link layer type, with class 0
being "LINKTYPE_ values", but the original use case doesn't appear ever
to have been used).
2022-03-04 16:23:02 -08:00
Stig Bjørlykke 71cb58df22 packetlogger: Handle SCO data packets
Add handling of sent and received SCO data packets.

Fixes #17964.
2022-02-28 10:04:50 +01:00
Guy Harris c7f84156c0 pcap/pcapng: byte-swap the CAN ID field in CAN pseudo-headers for SLL2.
As for LINUX_SLL, so for LINUX_SLL2.
2022-02-20 10:38:55 -08:00
Alexis La Goutte 123a5f4e13 libpcap(wiretap): Fix unreachable-code
libpcap.c:1007:19: warning: code will never be executed [-Wunreachable-code]
2022-02-13 10:23:43 +00:00
Alexis La Goutte f5eceb4ad0 blf: fix Wunreachable-code
blf.c:764:47: warning: code will never be executed [-Wunreachable-code]
2022-02-13 10:23:42 +00:00
David Perry 1e0d117eb7 Specify directory for temporary captures 2022-02-09 14:32:28 +00:00
Guy Harris 0d357951c3 pflog: byte swap UID and PID fields in the header if necessary. 2022-02-01 16:20:21 -08:00
Vladimir Bespalov 5ecb57cb90 Add ZBOSS NCP protocol dissector 2022-01-30 09:34:26 +00:00
Gerald Combs 46cb5d5252 BLF: Make sure a struct is completely initialized.
Initialize infstream. Fixes

```
*** CID 1497282:    (UNINIT)
/builds/wireshark/wireshark/wiretap/blf.c: 506 in blf_pull_logcontainer_into_memory()
500             }
501
502             int ret = inflate(&infstream, Z_NO_FLUSH);
503             /* Z_OK should not happen here since we know how big the buffer should be */
504             if (Z_STREAM_END != ret) {
505                 ws_debug("inflate failed (return code %d) for LogContainer %d", ret, index_log_container);
>>>     CID 1497282:    (UNINIT)
>>>     Using uninitialized value "infstream.msg".
506                 if (infstream.msg != NULL) {
507                     ws_debug("inflate returned: \"%s\"", infstream.msg);
508                 }
509                 return FALSE;
510             }
511
/builds/wireshark/wireshark/wiretap/blf.c: 514 in blf_pull_logcontainer_into_memory()
508                 }
509                 return FALSE;
510             }
511
512             if (Z_OK != inflateEnd(&infstream)) {
513                 ws_debug("inflateEnd failed for LogContainer %d", index_log_container);
>>>     CID 1497282:    (UNINIT)
>>>     Using uninitialized value "infstream.msg".
514                 if (infstream.msg != NULL) {
515                     ws_debug("inflateEnd returned: \"%s\"", infstream.msg);
516                 }
517                 return FALSE;
518             }
519
/builds/wireshark/wireshark/wiretap/blf.c: 496 in blf_pull_logcontainer_into_memory()
490             infstream.avail_out = (unsigned int)tmp.real_length;
491             infstream.next_out  = buf;
492
493             /* the actual DE-compression work. */
494             if (Z_OK != inflateInit(&infstream)) {
495                 ws_debug("inflateInit failed for LogContainer %d", index_log_container);
>>>     CID 1497282:    (UNINIT)
>>>     Using uninitialized value "infstream.msg".
496                 if (infstream.msg != NULL) {
497                     ws_debug("inflateInit returned: \"%s\"", infstream.msg);
498                 }
499                 return FALSE;
500             }
501
```
2022-01-18 00:15:36 +00:00
Dr. Lars Völker 268582b553 Frame: Parsing of PCAPNG Option Block PEN 46254 2022-01-17 10:54:57 +00:00
Guy Harris c8c7479ace libpcap: set wth->priv to the libpcap_t before returning errors.
That ensures that it'll be freed on an error, fixing Coverity CID
1497311.
2022-01-16 11:25:48 -08:00
Guy Harris a9490f354c libpcap (wiretap): reorganize the file open code. 2022-01-16 10:06:50 +00:00
Dr. Lars Völker ef43fd48b4 tshark: improve robustness for PCAPNGs not starting with IDBs
The PCAPNG code assumes that PCAPNGs start with IDBs, which might not be
true. This patch adds a workaround for Tshark to process such files.
2022-01-16 08:55:24 +00:00
Dr. Lars Völker 4107d5dd6e BLF: improved checks to avoid hangs
Improvements to fix a few hang scenarios found by fuzzing.
2022-01-16 07:44:19 +00:00
Alexis La Goutte 112af30dd9 erf(wiretap): Fix Clang Warning Uninitialized argument value 2022-01-15 08:41:12 +00:00
Dr. Lars Völker dd663c8c7f BLF: Improve handling of zlib errors 2022-01-15 08:30:36 +00:00
Dr. Lars Völker e9d650362c BLF: improve debug log output 2022-01-14 21:51:29 +01:00
John Thacker 203820f3d0 wiretap: Register a systemd Journal Export Block
The block is lightweight and doesn't have any options so the create
function doesn't really do anything, but it needs to be registered
so that when systemd journal files are opened, the wtap_block_create()
call works and doesn't segfault. Fix #17875
2022-01-14 03:07:05 +00:00
Guy Harris 7da31cb139 libpcap: remove definition of unused structure.
We don't allocate a per-dumper private data structure, so there's no
need to define a structure type.
2022-01-13 11:46:36 -08:00
John Thacker a9e6f2660e wiretap: Fix description of Custom Block 2022-01-13 14:02:55 +00:00
Jérôme HAMM 7356889242 Adding secret management in DSB. 2022-01-07 13:42:33 +00:00
Роман Донченко 6b8c32fa7a rfc7468: allow multiple structures per file
It's common to put multiple certificates in one RFC 7468 file in order to store
a certificate chain, as described in the introduction to RFC 7468 itself.
Support this usage by presenting each such certificate (or any other encoded
structure - the code doesn't discriminate) as a separate packet.

The new parsing code supports arbitrary line lengths, so update the detection
code to support arbitrary line lengths as well. Instead of probing up to 20
lines, we now try to find the first pre-encapsulation boundary in the first
2048 bytes of the file. I chose this new limit so that it works roughly the
same in practice as the old one (it's equal to 20 lines times 80 characters
per line, rounded to a power of two).
2022-01-06 06:29:54 +00:00
Gerald Combs 27ccf26b4b BLF: Fix a coverity warning.
Fix

```
*** CID 1496851:  Resource leaks  (RESOURCE_LEAK)
/builds/wireshark/wireshark/wiretap/blf.c: 1621 in blf_read_apptextmessage()
1615         }
1616
1617         gchar *text = g_try_malloc0((gsize)apptextheader.textLength);
1618
1619         if (!blf_read_bytes(params, data_start + sizeof(apptextheader), text, apptextheader.textLength, err, err_info)) {
1620             ws_debug("not enough bytes for apptext text in file");
>>>     CID 1496851:  Resource leaks  (RESOURCE_LEAK)
>>>     Variable "text" going out of scope leaks the storage it points to.
1621             return FALSE;
1622         }
1623
1624         /* returns a NULL terminated array of NULL terminates strings */
1625         gchar **tokens = g_strsplit_set(text, ";", -1);
```
2022-01-05 05:21:25 +00:00
Dr. Lars Völker 19ed057563 BLF: Adding support to read interface names
This patch reads out the interface of the meta data in BLF to set the
interface names in Wireshark to these values.
2022-01-03 07:58:47 +00:00
João Valverde 12d39efdca Revert "epan: Initialize wiretap"
This reverts commit c15f2aadc1.

Crashes on exit. Needs more work.

Fixes #17821.
2022-01-01 16:23:04 +00:00
Gerald Combs 4e417b8e7c Windows: UTF-8 harder.
Set the process code page in wireshark.exe.manifest to UTF-8 as
described at

https://docs.microsoft.com/en-us/windows/apps/design/globalizing/use-utf8-code-page

Make sure each of our command line resource files includes our main
manifest. Rename wiretap.rc to libwiretap.rc to match our other libraries.
2022-01-01 08:09:12 +00: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 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 ce1dc88173 Fix stdio.h conversions to use the scanf macros 2021-12-19 23:49:55 +00:00
João Valverde 0ccd69e530 Replace g_strdup_printf() with ws_strdup_printf()
Use macros from inttypes.h.
2021-12-19 21:21:58 +00:00
João Valverde 22ee2764a7 Replace g_snprintf() with snprintf() (dissectors)
Use macros from inttypes.h with format strings.
2021-12-19 20:25:11 +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
John Thacker 67a4e70382 wiretap: have dummy IDBs set OPT_IDB_TSRESOL if needed
In wtap_dump_init_dumper(), when constructing a dummy IDB for files
that don't have one, if the tsprecision value is anything other than
the default, then the OPT_IDB_TSRESOL option also needs to be set.
Without it, for a pcapng the timestamps will be written according to the
tsprecision and time_units_per_second values, but when it is read,
the values will be interpreted incorrectly.

It would probably be better if the consistency of these values were enforced.
2021-12-15 14:04:58 +00:00
John Thacker 85a8de25a4 blf: Set OPT_IDB_TSRESOL
In addition to setting tsprecision and time_units_per_second, add
the OPT_IDB_TSRESOL option as well, because pcapng expects that to
be set if tsprecision is anything other than the default.
2021-12-15 07:22:51 +00:00
Gerald Combs fcf945f747 wiretap: Fix an underflow in pcapng.
Make sure account for our rounded option length when we process
opt_endofopt. Fixes #17755.
2021-12-02 04:06:59 +00:00
John Thacker cf0ecc4fe1 nstime: Support ISO 8601 basic format
Add support in iso8601_to_nstime for the ISO 8601 Basic date/time
format that lacks the - and : separators.
2021-12-01 20:50:37 -05:00
Moshe Kaplan 34454a5037 wiretap: Add header files to Doxygen
Add @file markers for wiretap
headers so that Doxygen will
generate documentation for them.
2021-11-29 21:59:23 -05:00
Moshe Kaplan 1c3a9af869 Add files with WS_DLL_PUBLIC to Doxygen
Add @file markers for most files that
contain functions exported with
WS_DLL_PUBLIC so that Doxygen will
generate documentation for them.
2021-11-29 21:27:45 +00:00
João Valverde c15f2aadc1 epan: Initialize wiretap
Clients of libwireshark should not be required to initialize
explicitly wiretap, if they don't use it themselves.
2021-11-27 08:41:01 +00:00
Michael Tuexen 2b52d14d62 BBLog: Fix the handling of skipped blocks 2021-11-20 00:10:28 +01:00
Michael Tuexen d11c069786 BBLog: Fix support of TCP window scaling
Rcv.Wind.Shift and Snd.Wind.Shift were not displayed correctly by
the BBLog dissector and the TCP dissector was not using the
information about the shift values available in the BBLog file.
2021-11-08 23:05:20 +00:00
Anders Broman 94b28aa79a Ericsson ENB log reader: Check the whole line for the magic string. 2021-11-03 05:04:38 +00:00
Federico Di Pierro d95935d969 dissectors: support sysdig new block type BLOCK_TYPE_SYSDIG_EVENT_V2_LARGE
The new block type enlarge payload lens up to 4B,
to support larger payload sizes.

Signed-off-by: Federico Di Pierro <nierro92@gmail.com>
2021-10-29 08:04:21 +00:00
Dr. Lars Völker c44e14a4ba BLF: Direction is not ignored anymore (BUGFIX)
This patch adds direction support, so that incoming and outgoing frames
can be differentiated.
2021-10-26 20:45:33 +00:00