Commit Graph

3702 Commits

Author SHA1 Message Date
Guy Harris 58907c0723 blf: change description and add/extend comments.
Call the Vector Informatik BLF format "Vector Informatik Binary Logging
Format (BLF) logfile", to give more details to people who don't
necessarily know what "BLF" means (British Lung Foundation?).

Note that in the introductory comments to blf.c and blf.h as well.

Note that we should perhaps report unknown flags/packet timestamp type
values as errors or warnings.

Note that we can, and should, report at least some 802.11 radio
information to our caller.
2022-08-21 01:34:41 -07:00
Dr. Lars Völker 3167105e2f BLF: Adding ObjectHeader format 2 and 3
This patch adds the format 2 and 3 of the ObjectHeader, so that the blf
code does not stop reading the file, when one of these header formats is
present.

Minor refactoring was necessary.
2022-08-21 01:02:48 +00:00
Stephen Hemminger 005169491e pcapng: add support displaying hash from pcapng
Add support for displaying one or more packet hashes that
have been recorded in EPB options.

A patch to add support for EPB hash option is pending for next
DPDK release.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
2022-08-20 06:12:28 +00:00
Guy Harris c725f35689 ascend: make the time stamp in the parser state a time_t.
It's set from the result of mktime(), which returns a time_t, and it's
assigned to a time_t that's ultimately assigned to the time_t secs
member of an nstime, so no reason for it to be a guint32.

This should squelch Coverity CID 1509354.
2022-08-16 18:40:20 -07:00
Guy Harris d48808dc76 5views: don't allow out-of-range time stamps.
This should squelch Coverity CID 1509355.
2022-08-16 18:03:48 -07:00
Guy Harris 7411bc298b nettl: don't allow out-of-range time stamps.
This should squelch Coverity CID 1509360.
2022-08-16 17:19:20 -07:00
Guy Harris efea61f405 libpcap: don't allow out-of-range time stamps.
This should squelch Coverity CID 1509363.
2022-08-16 16:38:03 -07:00
Guy Harris 7bc6771397 visual: don't allow out-of-range time stamps.
This should squelch Coverity CID 1509368.
2022-08-16 15:46:26 -07:00
Guy Harris 79219b5247 netxray: don't allow out-of-range time stamps.
This should squelch Coverity CID 1509369.
2022-08-16 14:46:44 -07:00
Guy Harris 09c5183878 Linux USB: fix incorrect values for the packet length.
When reading memory-mapped Linux capture files, fix up the "real" length
field, in case the file was written by a program doing a capture done
with a version of libpcap with a bug that causes it to incorrectly set
the "real" length for isochronous transfers.
2022-08-14 22:50:51 -07:00
Tomasz Moń bf26f538c6
wiretap: Do not silently limit capture length
Libpcap assumes that packet length is greater or equal to captured data
length. However, due to a bug in libpcap, it was possible for libpcap to
generate isochronous URB packets (WTAP_ENCAP_USB_LINUX_MMAPPED) with
captured data length greater than packet length. The discrepancy comes
from slightly different semantics in Linux kernel.

Linux kernel usbmon packet documentation mentions:
    unsigned int length;  /* 32: Length of data (submitted or actual) */
    unsigned int len_cap; /* 36: Delivered length */

Wireshark shows usbmon packet length as URB length (usb.urb_len) and
len_cap as Data length (usb.data_len). For usbmon isochronous IN packets
containing data (URB complete), usbmon length is "actual". Actual length
is the sum of payload packets length received from device. Delivered
length refers to the amount of data associated with usbmon packet, that
is the isochronous descriptors and actual isochronous data. There can be
multiple isochronous descriptors in single URB and the actual payload in
special cases can be noncontiguous (there can be gaps).

Libpcap when reading usbmon capture calculates packet length based on
usbmon packet structure size (64), "actual length" and number of
isochronous descriptors. This gives expected packet length as long as
there are no gaps between isochronous data. If there are gaps, the
calculated packet length will be smaller than delivered length.

Wireshark should show the frame length and captured length as provided
by the capture engine, even if the capture length is greater than frame
length. Silently limiting captured length essentially hides the issue
from the user and allows misbehaving capture engine to go unnoticed.

Passing unmodified Frame Length and Capture Length to dissectors (and
thus complete tvb) allows USB dissector to show all ISO Data fields
captured on Linux usbmon interface using bugged libpcap.

Fixes #18021
2022-08-03 18:50:53 +02:00
Roland Knall 885d6b7f73 wiretap: Fix urls in comments
The old ones are no longer valid and lead to 404
2022-07-10 16:05:30 +00:00
Tomasz Moń 88c8bb19e5
USBLL: Dissect speed specific linktypes
USB 2.0/1.1/1.0 devices (or 3.x and newer when connected to hosts that
are not Super-Speed capable) operate at one of three speeds:
  * Low-Speed (1.5 Mbps)
  * Full-Speed (12 Mbps)
  * High-Speed (480 Mbps)

Supporting speed specific linktypes allows speed specific dissection
without the need for user to manually set the speed.
2022-06-29 05:56:03 +02:00
Gerald Combs 056fd8a1e3 NSIS: Update some target and filenames.
Rename the following build targets, similar to the recent macOS target
name changes:

nsis_package_prep to wireshark_nsis_prep
nsis_package to wireshark_nsis

Rename some NSIS files to reflect that they're specific to Wireshark.
Update the documentation and CI configurations.
2022-06-02 16:33:31 -07:00
John Thacker 06871d27df wiretap: merge support for IDBs in the middle of a file
Support merging files with IDBs in the middle of the file.
Use wtap_get_next_interface_description when doing the initial
list of interfaces so that we can correctly get IDBs later.

Note that while IDB merge modes "any" and "none" work as expected, the
default "all" mode can't really work for IDBs in the middle of the file
without adding a two-pass mode. In "all" mode, if there are any such IDBs,
merge them with duplicates iff the interfaces at the beginning of the
files were merged.

Related to #15502 and #16542.
2022-06-02 12:51:52 +00:00
John Thacker 0d2e248a25 file: Only change the file descriptors on a Save with Copy
If we do a save with copy, so that we just copied the binary
file, everything in the wtap structure should be the same except
for the filename and the file descriptors, so just change that
instead of closing wtap and reopening it.

The current behavior of calling wtap_open_offline does not work
for files that have blocks (SHBs, IDBs, NRBs, DSBs, ISBs, etc.) in
the middle of the file instead of at the beginning, but we shouldn't
have to waste time rescanning the entire file either.

In the case where a specific file format reader was manually selected,
this will keep the same file format as selected instead of switching to
the auto-detection when opening the copy, just as SAVE_WITH_MOVE already
does and presumably what the user wants.

Update wtap_fdreopen to change the wtap struct's pathname if
wtap_fdreopen is called with a different filename than currently.

Fix #17472
2022-06-01 02:03:57 +00:00
John Thacker 1f1ee198f2 merge: Don't write to stdout if tempdir is not set
If merge_files_common() is called with a non NULL value for out_filenamep,
that always indicates tempfile mode, even if the tempdir is not set.
A NULL value for the tempdir is handled by wtap_dump_open_tempfile,
which writes to the OS default temp directory.

Only write to stdout if both out_filename and out_filenamep are NULL.

Fixes a crash introduced by commit 1e0d117eb7
when selecting Merge from the GUI and the new temp_dir option is not set.
2022-05-13 13:41:28 +00:00
Guy Harris 1ee8ead845 Provide the section number for blocks, and show it.
Add a "section number" field to wtap_rec, with a presence flag, and
provide the section number (0-based) for pcapng files.

Display it (1-based) if present.
2022-04-22 18:14:29 -07:00
Gerald Combs 62a2fe28c2 wiretap: Try opening systemd journal files before IxVeriWave.
The Ixia IxVeriWave .vwr file reader's heuristics matched a journal file
here, so place the systemd journal before it in the list.
2022-04-13 17:04:25 -07:00
Gerald Combs a0ae42e33b wiretap: Update a comment.
Wireshark's file formats are now listed in WiresharkInfo.plist.in.
2022-04-06 07:44:33 -07:00
João Valverde fbd32cf853 Replace g_log() calls with ws_log() 2022-04-04 01:33:58 +00:00
Richard Sharpe e61fe552d0 ieee80211-radiotap: Add support for headers to be bit-based as well as TLVs.
Johannes Berg pointed out this was the intent of the TLV definitions and
supplied some code for implementing that. I simply made it work.
2022-03-17 22:26:12 +00:00
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