Commit Graph

361 Commits

Author SHA1 Message Date
Martin Mathieson e0300eaed8 Fix lots of spellings 2024-02-25 22:46:47 +00:00
Stig Bjørlykke b14d9c963c Remove init of tap variables
A tap_id is never 0, so initializing tap variables to -1 is not
necessary.
2023-12-06 13:07:05 +00:00
Stig Bjørlykke 2a9bc63325 Remove init of proto variables
Remove init of proto, header field, expert info and subtree variables.
This will reduces the binary size by approximate 1266320 bytes due to
using .bss to zero-initialize the fields.

The conversion is done using the tools/convert-proto-init.py script.
2023-11-20 08:20:54 +01:00
Jason Tang ec001766f6 WSLua DissectorTable GUID Support 2023-11-01 22:01:15 +00:00
Guy Harris 45fc52bad9 dcerpc: just use structure assignment rather than memcpy. 2023-08-24 16:08:32 -07:00
John Thacker 1db595d1bd Decode As: Keep current handle and description consistent
Make the current dissector description and handle private
members of DecodeAsItem, and change them in tandem.
2023-05-22 07:24:14 -04:00
David Perry 5468611d57 Use `register_dissector()` for more protocols
Changes several calls of `create_dissector_handle()` to instead call
`register_dissector()` with a name for the dissector.

This should handle all dissectors in `epan/` from `packet-a*` to
`packet-d*`.

This change allows affected dissectors to be findable by calls to
`find_dissector()`. In turn, this opens up more command-line use for
these protocols, including fuzzshark and rawshark, as well as lua use
via `Dissector.get()`.

Where needed, move the call from the protocol handoff function to the
protocol register function, and use `find_dissector()` in the handoff
function.

There were some calls to `create_dissector_handle()` or
`register_dissector()` which passed `-1` as the protocol argument. When
I saw those I corrected them to pass the actual `proto_foo` identifier
instead.

Partially addresses #5612
2023-05-16 08:18:10 +00:00
John Thacker ebbd943c85 Qt: Simplify Decode As handling
We want to default to the last Decode As table with an entry in
the packet. Since the list of layers is a doubly-linked list,
start with the tail and go backwards for simpler and faster logic.

Move the logic for how to create a DecodeAsItem from a decode_as_t
into the constructors.
2023-05-14 02:56:59 +00:00
John Thacker 15fd2ddc8c columns: Migrate two-field columns to custom columns
Migrate some built in columns that correspond exactly to only two or
three fields to custom columns. The last time column customification
was done, multifield custom columns didn't exist. This simplifies
the GUI for most users, and also means that when these columns do
exist, "Apply as Filter" will work as expected.

COL_8021Q_VLAN_ID, COL_VSAN, COL_DCE_CALL, COL_TEI

Related to #13941
2023-05-05 11:05:20 +00:00
Martin Mathieson 1a29060159 Address more warnings from check_typed_item_calls.py 2023-03-23 11:53:53 +00:00
Guy Harris c9342873e5 Clarify dissector description, protocol short name, and protocol ong name.
Rename dissector_handle_get_long_name() and
dissector_handle_get_short_name() to
dissector_handle_get_protocol_long_name() and
dissector_handle_get_protocol_short_name(), to clarify that they fetch
names for the protocol that the dissector dissects, not for the
dissector *itself*.  Leave a deprecated
dissector_handle_get_short_name() wrapper, and export
dissector_handle_get_protocol_long_name(), as it's now used in some
dissectors.

Change some calls to dissector_handle_get_description() back to
dissector_handle_get_protocol_short_name(), as they appear to be made in
order to display a *protocol* name.

Rename some methods, variables, enums, and table column names to reflect
cases where the dissector description is being used.
2022-09-13 00:47:24 -07:00
Guy Harris d4394de669 Give dissectors a descriptive string.
It defaults to the short name of the protocol dissected by the
descriptor, but it's now possible to register a dissector with an
explicit description.

This is mainly for use in the Decode As UI.  It handles the case where
the same protocol might have different "Decode As..."-specifiable
dissectors for different situations.
2022-09-12 21:05:14 +00:00
Guy Harris 8195bdd340 Rename a bunch of things with "conversation".
A conversation in Wireshark might have two endpoints or might have no
endpoints; few if any have one endpoint.  Distinguish between
conversations and endpoints.
2022-08-25 20:02:20 -07:00
John Thacker f1cbc6b662 epan: Remove fragment_get_reassembled()
Because completed reassemblies are hashed in the reassembled_table for
all the frame numbers that contributed fragments,
fragment_get_reassembled_id() works wherever fragment_get_reassembled()
does, and also works where the fragment id is not the frame number.

However, since the reassembled_table hash key only depends on the
fragment id and the frame number, it only allows a frame to have
one reassembly with a given fragment id. Some protocols can have
more than one reassembly with a given fragment id (that differ on
addresses or other keys), such as GSM SMS, and the wrong reassembly
is retrieved on the second pass in those cases.

For this reason, we might want to add additional key elements to
reassembled_table, such as layer number. fragment_get_reassembled_id
already takes packet_info as a parameter and can accommodate that
without further changes, but fragment_get_reassembled cannot, so
remove the latter in favor of the former.
2022-06-14 00:59:34 +00:00
Roland Knall 2cf938cfa8 tap: Adding flags for tap_packet
This allows flags to be passed by the registering listener
to the collection of information
2022-06-10 05:46:15 +00:00
João Valverde 8efad466c4 Tools: Fix fix-encoding-args.pl ASCII string validation
Do not require a useless ENC_NA parameter for string encodings.
FT_STRING and FT_STRINGZ types don't have any ndianness.

Follow-up to 6ec429622c.
2022-02-15 11:38:16 +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
Jaap Keuter adbaced04c Dissectors should not include stdio.h, unless needed 2021-12-05 12:45:46 +00:00
John Thacker 11298a5b2c DCERPC: Strengthen heuristic, fix PDU length
The fragment length field of DCERPC connection-oriented PDUs includes
the length of the fixed header, and so must be at least that large.
Don't return a (bogus) PDU length zero from get_dcerpc_pdu_len,
because tcp_dissect_pdus interprets that as "need one more segment"
instead of as a bogus value; instead return one, which the TCP
dissector will correctly recognize as bogus.

Also, take into account the offset passed into get_dcerpc_pdu_len
(it is almost always 0, which is why the code previously worked),
and increase the fixed length value passed to tcp_dissect_pdus
to the real fixed header length (so that the TCP dissector will
recognize more bogus values as bogus.)
Fix #14728.
2021-10-22 23:16:39 -04:00
Evan Huus 3cdada3e7b guids: wmem-scope lookups
Avoids the use of the global unprotected packet memory pool and lets the
compiler enforce scoping.
2021-09-28 15:07:55 -04:00
David Perry 6e8c7283d6 Change some `wmem_packet_scope()` to `pinfo->pool` 2021-07-27 21:36:43 +00:00
Chuck Craft a7d927a9e9 prefs_register_protocol_obsolete protocols with only obsolete prefs
Related to #17465 and !3526
2021-07-13 23:12:04 +00:00
Alexis La Goutte 558a32ba86 dcerpc: Fix warning found by Clang Analyzer
packet-dcerpc.c:4381:17: warning: Assigned value is garbage or undefined [core.uninitialized.Assign]
2021-06-22 20:30:13 +00:00
Guy Harris 57a1514ac7 Cast away the return value of g_strlcpy() and g_strlcat().
Most of the time, the return value tells us nothing useful, as we've
already decided that we're perfectly willing to live with string
truncation.  Hopefully this keeps Coverity from whining that those
routines could return an error code (NARRATOR: They don't) and thus that
we're ignoring the possibility of failure (as indicated, we've already
decided that we can live with string truncation, so truncation is *NOT*
a failure).
2021-04-30 03:19:19 -07: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
Alexis La Goutte 71ea1f9017 dcerpc: Fix Dead Store
Fix dead store (Dead assignement/Dead increment) Warning found by Clang
2020-09-29 18:53:21 +00:00
Guy Harris 77b67c7357 dcerpc: add more URLs.
https://pubs.opengroup.org/onlinepubs/009629399/ dumps you into a
directory; give URLs that take you to the table of contents for the HTML
and PDF versions.

Change-Id: I45da12025f27a0c101087fd12d2de75a0720baa6
Reviewed-on: https://code.wireshark.org/review/38214
Reviewed-by: Guy Harris <gharris@sonic.net>
2020-08-21 02:12:46 +00:00
John Thacker aa6b8f59af DCERPC: Make heuristics more discriminating
Make the DCE/RPC heuristics a bit more discriminating by checking
a few more header fields for illegal values. Reduces false positives.

Change-Id: Ic3d6c7ce62b64b2042922adb104294600b0db673
Reviewed-on: https://code.wireshark.org/review/38028
Petri-Dish: Anders Broman <a.broman58@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2020-08-03 11:30:37 +00:00
Martin Mathieson 570a0cb301 Set member variables in initialiser list (rather than in CTOR bodies).
Also simplify some boolean logic in packet-dcerpc.c.
All reported by cppcheck.

Change-Id: I2075f2ec10dc777ad7635da4ef056d17fc5b0be0
Reviewed-on: https://code.wireshark.org/review/37609
Petri-Dish: Martin Mathieson <martin.r.mathieson@googlemail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
Reviewed-by: Martin Mathieson <martin.r.mathieson@googlemail.com>
2020-06-30 12:11:15 +00:00
Guy Harris e1d9a226a2 Fix the type of arrays of pointers to hf_ values for bitfield routines.
The static arrays are supposed to be arrays of const pointers to int,
not arrays of non-const pointers to const int.

Fixing that means some bugs (scribbling on what's *supposed* to be a
const array) will be caught (see packet-ieee80211-radiotap.c for
examples, the first of which inspired this change and the second of
which was discovered while testing compiles with this change), and
removes the need for some annoying casts.

Also make some of those arrays static while we're at it.

Update documentation and dissector-generator tools.

Change-Id: I789da5fc60aadc15797cefecfd9a9fbe9a130ccc
Reviewed-on: https://code.wireshark.org/review/37517
Petri-Dish: Guy Harris <gharris@sonic.net>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2020-06-19 11:32:26 +00:00
Moshe Kaplan fd7895d37c Replace instances of wmem_alloc with wmem_new
This commit replaces instances of
  (myobj *)wmem_alloc(wmem_file_scope(), sizeof(myobj))
and replaces them with:
  wmem_new(wmem_file_scope(), myobj)
to improve the readability of Wireshark's code.

The replacement locations were identified with grep
and replaced with the Python script below.

grep command:
  egrep "wmem_alloc0?\(wmem_file_scope\(\), sizeof\([a-z_]+\)\)" . -R -l

python script:

import re
import sys
import fileinput

pattern = r'\(([^\s]+) ?\*\) ?wmem_alloc(0?)\((wmem_[a-z]+_scope\(\)), sizeof\(\1\)\)'
replacewith = r'wmem_new\2(\3, \1)'

fname = sys.argv[1]

for line in fileinput.input(fname, inplace=1, mode='rb'):
    output = re.sub(pattern, replacewith, line)
    sys.stdout.write(output)

Change-Id: Ieac246c104bf01e32cbc6e11e53e81c7f639d870
Reviewed-on: https://code.wireshark.org/review/37158
Petri-Dish: Pascal Quantin <pascal@wireshark.org>
Tested-by: Petri Dish Buildbot
Reviewed-by: Pascal Quantin <pascal@wireshark.org>
2020-05-07 14:47:54 +00:00
Stefan Metzmacher 6afa37bb1a packet-dcerpc: pass down header/trailer for hdr_signing
Change-Id: I1d14ffe928e1b303eee7e95a45a9617ffcfb151b
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-on: https://code.wireshark.org/review/35707
Petri-Dish: Anders Broman <a.broman58@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2020-01-22 21:06:57 +00:00
Pascal Quantin 1628bff78d Get rid of proto_tree_add_debug_text() calls
This function should not be used for anything else than debug, as stated
in its name.

Bug: 15989
Change-Id: Ie2a99f3487169fcf2d00c06e7fc5d61086f32969
Reviewed-on: https://code.wireshark.org/review/34954
Petri-Dish: Pascal Quantin <pascal@wireshark.org>
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Pascal Quantin <pascal@wireshark.org>
2019-11-04 14:22:05 +00:00
Ralph Boehme c9f2b9b3ed DCERPC: workaround that pidl always emits dissect_deferred_pointers()
Commit f57cf9e56c introduced a DISSECTOR_ASSERT()
that revealed a deficiency in pidl: currently pidl unconditionally adds calls to
dissect_deferred_pointers() which breaks dissecting any RPC function that
has only scalar arguments:

  Warn Dissector bug, protocol RPCMDSSVC, in packet 51:
  epan/dissectors/packet-dcerpc.c:2940:
  failed assertion "list_ndr_pointer_list"

Bug: 16022
Change-Id: I9d3522a3e17ef79b9a8a5acb018104ab398a512a
Reviewed-on: https://code.wireshark.org/review/34364
Petri-Dish: Alexis La Goutte <alexis.lagoutte@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2019-08-27 04:02:39 +00:00
Guy Harris 245086eb83 HTTPS In Still More Places, update more URLs.
Microsoft reshuffled their documentation - almost all of it moved from
msdn.microsoft.com to docs.microsoft.com.  Some blogs moved to
devblogs.microsoft.com; the comments *didn't* move, so in one case we go
to the Wayback Machine - the link isn't dead, but it formats horribly,
at least on my browser, but the archived version formats OK.

Use the Wayback Machine for some URLs, and update others.

Update the sections for MS-ADTS.

Point to the HTML versions of some RFCs and I-Ds.

Change-Id: I344b20f880de63f1ae2a4e3f9ff98af78a7fe139
Reviewed-on: https://code.wireshark.org/review/34101
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2019-07-27 22:56:35 +00:00
Guy Harris 20800366dd HTTPS (almost) everywhere.
Change all wireshark.org URLs to use https.

Fix some broken links while we're at it.

Change-Id: I161bf8eeca43b8027605acea666032da86f5ea1c
Reviewed-on: https://code.wireshark.org/review/34089
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2019-07-26 18:44:40 +00:00
Martin Kaiser f155601d66 decode_as: remove the "title" member from decode_as_t
The title of a decode_as_t was used by the GTK UI. It's no
longer required for Qt.

Change-Id: Ibd9d4acbe9cad2c1af520340d04e550326a97ebe
Reviewed-on: https://code.wireshark.org/review/33557
Petri-Dish: Martin Kaiser <wireshark@kaiser.cx>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2019-06-11 18:50:32 +00:00
Gerald Combs 8d3ac3af86 epan: Convert our PROTO_ITEM_ macros to inline functions.
Convert our various PROTO_ITEM_ macros to inline functions and document
them.

Change-Id: I070b15d4f70d2189217a177ee8ba2740be36327c
Reviewed-on: https://code.wireshark.org/review/32706
Reviewed-by: Gerald Combs <gerald@wireshark.org>
Petri-Dish: Gerald Combs <gerald@wireshark.org>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2019-04-04 04:03:38 +00:00
Guy Harris cced5fb949 Constification, to remove some compiler warnings.
Change-Id: I24f0bdc72109a6ef3d801dc28cb9b523ff4e5fe7
Reviewed-on: https://code.wireshark.org/review/32458
Petri-Dish: Guy Harris <guy@alum.mit.edu>
Tested-by: Petri Dish Buildbot
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2019-03-17 21:09:34 +00:00
Jiajun Wang fc0e5d48d5 DCERPC: fix parsign of big endian UTF-16 string
Change-Id: I560afb78bd3a06fd4f8a2d619dc2ff3bd6567a52
Reviewed-on: https://code.wireshark.org/review/32099
Petri-Dish: Anders Broman <a.broman58@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2019-02-20 06:08:44 +00:00
Guy Harris 2d41b15495 Add a "failed" return for tap packet routines.
This allows taps that can fail to report an error and fail; a failed
tap's packet routine won't be called again, so they don't have to keep
track of whether they've failed themselves.

We make the return value from the packet routine an enum.

Don't have a separate type for the per-packet routine for "follow" taps;
they're expected to act like tap packet routines, so just use the type
for tap packet routines.

One tap packet routine returned -1; that's not a valid return value, and
wasn't one before this change (the return value was a boolean), so
presume the intent was "don't redraw".

Another tap routine's early return, without doing any work, returned
TRUE; this is presumably an error (no work done, no need to redraw), so
presumably it should be "don't redraw".

Clean up some white space while we're at it.

Change-Id: Ia7d2b717b2cace4b13c2b886e699aa4d79cc82c8
Reviewed-on: https://code.wireshark.org/review/31283
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2019-01-01 05:03:42 +00:00
Guy Harris 7eb3e47fa4 Try to squeeze some bytes out of the frame_data structure.
Make the time stamp precision a 4-bit bitfield, so, when combined with
the other bitfields, we have 32 bits.  That means we put the flags at
the same structure level as the time stamp precision, so they can be
combined; that gets rid of an extra "flags." for references to the flags.

Put the two pointers next to each other, and after a multiple of 8 bytes
worth of other fields, so that there's no padding before or between them.

It's still not down to 64 bytes, which is the next lower power of 2, so
there's more work to do.

Change-Id: I6f3e9d9f6f48137bbee8f100c152d2c42adb8fbe
Reviewed-on: https://code.wireshark.org/review/31213
Petri-Dish: Guy Harris <guy@alum.mit.edu>
Tested-by: Petri Dish Buildbot
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2018-12-27 04:34:29 +00:00
Peter Wu f57cf9e56c DCERPC: fix memleak by removing dummy element from ndr_pointer_list
Instead of creating the pointers list early, defer it to the point when
a new list item is added. This avoids the need for a dummy element.

This happens to fix the memory leak in bug 14735 as well (verified with
both ASAN and valgrind).

Change-Id: I3b169dfc447bd7465d06c26e0bd9dfd4225b1307
Bug: 14735
Reviewed-on: https://code.wireshark.org/review/30115
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-10-12 05:07:58 +00:00
Peter Wu 0e0e56d05b DCERPC: simplify pointer list tracking
Observe that the "current_depth" and "len_ndr_pointer_list" just track
the length of the current singly linked list in order to insert (append)
or remove [the last] element (a linked list of lists and a linked list
of pointers respectively). Replace these callers by equivalents that do
not require explicit length tracking, internally they both have to do a
O(n) lookup anyway.

There used to be a case where "current_depth" could run out-of-sync, no
longer tracking the actual list length: when the callback (tnpd->fnct or
tnpd->callback) triggers an exception. I believe this was unintentional.

No functional change intended, but this should make further changes to
the data structures easier.

Change-Id: I3cb13aba22caa87dc7baba411cf34f47792f7bb7
Ping-Bug: 14735
Fixes: v2.5.0rc0-292-g6bd87bdd5d ("dcerpc: improve greatly the speed of processing of DCERPC packets")
Reviewed-on: https://code.wireshark.org/review/30114
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-10-12 05:07:33 +00:00
Peter Wu b6d182859e DCERPC: remove unused variable and mark another global as static
dcerpc_hooks_init_protos is unused since v1.11.3-rc1-34-g01c8945438.
uuid_dissector_table was added in v2.1.0rc0-391-ge0e574d167 and was not
used outside the file, so mark it as static.

Change-Id: I6113fbaf1f2e2e6241b91b659711986d6e6ded66
Reviewed-on: https://code.wireshark.org/review/30116
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
2018-10-11 10:27:31 +00:00
Guy Harris 9e480c51bb Distinguish between "reserved for implementation" and "reserved for future use".
Some flags in the connectionless PDU header are "reserved for
implementation", which presumably means an implementation can set them
to 0 or 1 and use it to send information to a compatible implementation;
others are "reserved for future use" and "must be set to 0".

Don't test the "reserved for implementation" flags in the heuristic, and
show them as "Reserved for implementation" and show the others as
"Reserved for future use (MBZ)".

Bug: 14942
Change-Id: Iff40f155e057301096fec1dbb68f71d041508ff1
Reviewed-on: https://code.wireshark.org/review/28598
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2018-07-04 22:52:13 +00:00
Guy Harris 3a0dd69d04 Get rid of some GTK+-only stuff.
Change-Id: I841a1cdb637f37673466e4d065474c0f7e2dfc56
Reviewed-on: https://code.wireshark.org/review/27512
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2018-05-13 19:46:45 +00:00
Anders bb81bef535 glib: Get rid of GLIB_CHECK_VERSION as we now require 2.32.0
Change-Id: Ie95cf37f9cd283545693e290340a7489cc989c95
Reviewed-on: https://code.wireshark.org/review/26970
Petri-Dish: Anders Broman <a.broman58@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-04-16 16:07:46 +00:00
Guy Harris 397d32b863 dcerpc_decode_as_change() doesn't need to change the old binding.
The search doesn't use the fields we change (if it did, we probably
shouldn't change them, as the old binding might not be found), so don't
change them.

Instead, when we allocate a *new* binding structure, put the new values
into *that* structure.

Squelches a "casting away constness" warning.

Change-Id: I6dbd1a4cbc2415373f4926f443f9756c8113c0be
Reviewed-on: https://code.wireshark.org/review/25841
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2018-02-17 20:20:08 +00:00