Commit Graph

1120 Commits

Author SHA1 Message Date
Guy Harris 67e70dcad2 proto: clean up comments.
Say "attempt to XXX", as the attempt might not succeed.

Fix a copied-and-pasted comment to reflect what
proto_is_frame_protocol() does.

Change-Id: Ia16a98064b87001f019fda43f2db2970a89e355e
Reviewed-on: https://code.wireshark.org/review/37486
Reviewed-by: Guy Harris <gharris@sonic.net>
2020-06-16 08:34:03 +00:00
Uli Heilmeier 66d5bb9dbe proto.c: check for proto_item_get_display_repr()
Check if proto item exists

Bug: 16592
Change-Id: Ida6950e94dfee935e448198df6199e96b1140aa2
Reviewed-on: https://code.wireshark.org/review/37350
Petri-Dish: Jaap Keuter <jaap.keuter@xs4all.nl>
Tested-by: Petri Dish Buildbot
Reviewed-by: Jaap Keuter <jaap.keuter@xs4all.nl>
2020-06-06 14:51:22 +00:00
Guy Harris 9f03cde5a5 Add a routine to get the representation of a protocol tree item and use it.
Add proto_item_get_display_repr(), which returns a string, allocated
with a specified wmem scope, containing the display representation of
the value of a proto_item.

Use it in the LLDP dissector, to append that string to the parent
protocol tree item; use packet scope, so it doesn't hang around forever
(the previous code used the NULL scope, meaning explicit freeing was
required, but it wasn't explicitly freeing the value, so it was
leaking).

Change-Id: I146380118833b1daef9dea8bd9463001e5b9325f
Reviewed-on: https://code.wireshark.org/review/36931
Petri-Dish: Guy Harris <gharris@sonic.net>
Reviewed-by: Guy Harris <gharris@sonic.net>
2020-04-25 06:27:53 +00:00
Jaap Keuter 9750d00ff1 Introduce tfs_get_string helper
true_false_strings have no helper function to properly retrieve the
string representing the true or false value, much like unit_strings,
even though this is not uncommon in dissectors.
This change introduces the helper function and modifies the dissectors,
so that they use this helper i.s.o. their own expressions.

Change-Id: I477ed2d90a9a529fc5dcfef7e3ea42ec180d27ae
Reviewed-on: https://code.wireshark.org/review/36920
Reviewed-by: Jaap Keuter <jaap.keuter@xs4all.nl>
Petri-Dish: Jaap Keuter <jaap.keuter@xs4all.nl>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2020-04-25 04:39:46 +00:00
Martin Kaiser 55d3d32239 proto: remove a temporary variable
In proto_tree_add_item_ret_time_string, we should return the result of
proto_tree_add_node directly like other similar functions.

Change-Id: I5f0cdc32ee3e69ecf3c62f1d56cb8278c91c9c45
Reviewed-on: https://code.wireshark.org/review/36716
Reviewed-by: Martin Kaiser <wireshark@kaiser.cx>
Petri-Dish: Martin Kaiser <wireshark@kaiser.cx>
Tested-by: Petri Dish Buildbot
Reviewed-by: Guy Harris <gharris@sonic.net>
2020-04-05 18:22:35 +00:00
Martin Mathieson ec781e9749 proto: Add a debug check to sanity-check range_string
Check is enabled by #ifdef ENABLE_CHECK_FILTER
Remaining issues found by this check are fixed here,
along with a documentation note that the entries
are checked in order and the first match is used.

The only issue not yet fixed is in packet-isup.c,
where the spec was not available to me.

Change-Id: Ife747cda9b91a265bc2b81ce0a53f55f3389919e
Reviewed-on: https://code.wireshark.org/review/36708
Petri-Dish: Martin Mathieson <martin.r.mathieson@googlemail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Martin Mathieson <martin.r.mathieson@googlemail.com>
2020-04-05 17:40:21 +00:00
Dario Lombardo 3885912cca proto: fix invalid types in hf check routine.
The conditional code compiles with ENABLE_CHECKHF_CONFLICT=1.
The mix of string_value and string_value64 requires to split
up the code, and a macro seems to be the most suitable solution
since types are involved.

The error raises on Ubuntu 18.04:

FAILED: epan/CMakeFiles/epan.dir/proto.c.o
/usr/bin/cc -DG_DISABLE_DEPRECATED -DG_DISABLE_SINGLE_INCLUDES -DWS_BUILD_DLL -Depan_EXPORTS -I. -I../ -isystem /usr/include/glib-2.0 -isystem /usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/lua5.2 -I/usr/include/libxml2 -Iepan -I../epan -fvisibility=hidden  -fexcess-precision=fast -Wall -Wextra -Wendif-labels -Wpointer-arith -Wformat-security -fwrapv -fno-strict-overflow -Wvla -Waddress -Wattributes -Wdiv-by-zero -Wignored-qualifiers -Wpragmas -Wno-overlength-strings -Wno-long-long -Wframe-larger-than=32768 -Wc++-compat -Wunused-const-variable -Wshadow -Wold-style-definition -Wstrict-prototypes -Wlogical-op -Wjump-misses-init -Werror=implicit -Wno-pointer-sign -std=gnu99  -O2 -g -DNDEBUG -fPIC   -isystem /usr/include/mit-krb5 -Werror -MD -MT epan/CMakeFiles/epan.dir/proto.c.o -MF epan/CMakeFiles/epan.dir/proto.c.o.d -o epan/CMakeFiles/epan.dir/proto.c.o   -c ../epan/proto.c
../epan/proto.c: In function ‘tmp_fld_check_assert’:
../epan/proto.c:8013:18: error: assignment from incompatible pointer type [-Werror=incompatible-pointer-types]
     start_values = VAL64_STRING_EXT_VS_P(((const val64_string_ext*)hfinfo->strings));
                  ^
cc1: all warnings being treated as errors
[27/388] Building CXX object ui/qt/CMakeFiles/qtui.dir/coloring_rules_dialog.cpp.o
ninja: build stopped: subcommand failed.

Change-Id: I77c424bac96a1bbe81c0826faef66df7cc476ec4
Reviewed-on: https://code.wireshark.org/review/36604
Reviewed-by: Martin Mathieson <martin.r.mathieson@googlemail.com>
Petri-Dish: Martin Mathieson <martin.r.mathieson@googlemail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2020-04-02 07:47:23 +00:00
Martin Mathieson 71e9009825 Check for true_false_string with identical true/false string.
Fixed a few instances where fix were obvious, others are
less clear.
The check in proto.c is protected by ENABLE_CHECK_FILTER.

Change-Id: I4edee4e67bd53bbf2eb809d68c87983a7c5a66f3
Reviewed-on: https://code.wireshark.org/review/36645
Reviewed-by: Martin Mathieson <martin.r.mathieson@googlemail.com>
2020-04-01 10:32:08 +00:00
Jakub Adam 732aa60098 proto: fix get_time_value() for ENC_TIME_CLASSIC_MAC_OS_SECS
Times before 1970-01-01 should be represented as a negative number of
seconds in nstime_t.

e.g. MP4 creation_time of 0x00000000 (which appears frequently as the
default in mp4 files) was rendered as Feb 6, 2040 07:28:16 CET

Change-Id: I979aeeb8a625caad3dfbce114cff6f9967d59d6e
Reviewed-on: https://code.wireshark.org/review/35904
Petri-Dish: Alexis La Goutte <alexis.lagoutte@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2020-01-26 19:23:29 +00:00
Guy Harris a152e041fa Put various epoch time deltas into wsutil/epochs.h.
There are some deltas between the UN*X epoch and other epochs that are
used in a number of places; put them into a header.

Change-Id: Ia2d9d69b9d91352d730d97d9e4897518635b4861
Reviewed-on: https://code.wireshark.org/review/35895
Petri-Dish: Guy Harris <guy@alum.mit.edu>
Tested-by: Petri Dish Buildbot
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2020-01-21 23:37:05 +00:00
Guy Harris 3d2ccf4a9e Rename a time variable to reflect its units.
The S/370-and-later TOD clock counts in microseconds, not seconds.

Change-Id: I0b11586df073ed589d69ffc014e6f8661dff3d31
Reviewed-on: https://code.wireshark.org/review/35891
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2020-01-21 20:57:31 +00:00
Guy Harris fc31446277 Add support for "classic Mac OS" timestamps and use them in file-mp4.c.
Those times are in seconds since January 1, 1904, 00:00:00 (proleptic?)
UTC.

MPEG-4 Part 14 (MP4) is based on QuickTime, so it uses classic Mac OS
time stamps, in seconds.

Change-Id: Ibcd7faf1b119d8acbb294c95b66ca0d1fb70cbb3
Reviewed-on: https://code.wireshark.org/review/35886
Petri-Dish: Guy Harris <guy@alum.mit.edu>
Tested-by: Petri Dish Buildbot
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2020-01-21 20:54:25 +00:00
Pascal Quantin 99398c533e Fix display of pino protocols in display filter dropdown
Qt GUI uses proto_get_first_protocol() to find the list of protocols
and build the autocompletion list. As pinfo protocols are stored in
another list, they are kept aside.
Let's add them in the same list as normal protocols.

Bug: 16130
Change-Id: I9ff67ea4198a8cc6baf3ded584c48eadfb097092
Reviewed-on: https://code.wireshark.org/review/34778
Reviewed-by: Michael Mann <mmann78@netscape.net>
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot
Reviewed-by: Pascal Quantin <pascal@wireshark.org>
2019-11-12 06:20:38 +00:00
Stig Bjørlykke 551745998e wslua: Fix memleak of unregistered ProtoField strings
If a ProtoField object was created, but not linked to a Proto, then the
strings field and all elements (depending on type) would leak.

This is a follow-up to g79fef2ae and fixes the real issue in g44870fb1.

Change-Id: I01880a92bb20fae45f68c754b07daeb07630deec
Reviewed-on: https://code.wireshark.org/review/34872
Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org>
Tested-by: Petri Dish Buildbot
Reviewed-by: Vasil Velichkov <vvvelichkov@gmail.com>
Reviewed-by: Roland Knall <rknall@gmail.com>
2019-10-28 15:05:54 +00:00
Michael Mann 168ee5003f kafka: Cleanup to use "native" APIs.
Add "native" support for the "zig-zag" version of a varint in proto.[ch] and
tvbuff.[ch].  Convert the use of varint in the KAFKA dissector to use the (new)
"native" API.

Ping-Bug: 15988
Change-Id: Ia83569203877df8c780f4f182916ed6327d0ec6c
Reviewed-on: https://code.wireshark.org/review/34386
Petri-Dish: Alexis La Goutte <alexis.lagoutte@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2019-09-05 03:25:39 +00:00
Anders Broman 98cda1bf46 Load environment vars to globals for efficency.
These environment variables are read very frequently, read them once to
globals for performance improvment.

Change-Id: I4f05a5edca85b370674cc5f85fce40bd1af695cb
Reviewed-on: https://code.wireshark.org/review/34449
Petri-Dish: Anders Broman <a.broman58@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2019-09-04 12:31:53 +00:00
Michael Mann 01d7793976 Add proto_tree_add_item_ret_time_string
A few dissectors need the functionality of adding a time field to a proto_tree
while also needing the "time to string" value (typically to show on a tree above).
The functionality to do "get value from tvb and convert to string" was being done
in packet-ntp.c.
Instead proto_tree_add_item_ret_time_string can be used with various encoding to
get the necessary functionality with less code duplication.

ENC_TIME_MIP6 was added as a result of the refactoring.
ABSOLUTE_TIME_NTP_UTC was added as another potential "base" type for time fields.

Change-Id: Ie460c33370b0af59ef60bdab893ce9d6eb23b94f
Reviewed-on: https://code.wireshark.org/review/34390
Petri-Dish: Anders Broman <a.broman58@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2019-08-29 13:31:48 +00:00
Peter Wu 77b6160696 proto: fix proto_item_add_bitmask_tree with zero length
packet-frame.c calls proto_item_add_bitmask_tree with a zero length, be
sure not to trigger undefined behavior (right shift by 64). Observed
with the capture from Bug 15247.

Change-Id: I5b5b7f920a37365295603be7b915f51b39d99faf
Fixes: v2.1.0rc0-1776-gb9fb2ceb88 ("Add heuristic dissectors for the variable part of COTP CR and CC PDUs.")
Reviewed-on: https://code.wireshark.org/review/34108
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
2019-07-29 20:50:45 +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
Guy Harris edd5eaa57e Don't format printable non-ASCII Unicode characters as escape sequences.
Note that even strings fetched with ENC_ASCII may contain them - bytes
with the 8th bit set get mapped to REPLACEMENT CHARACTER.

This means we can format STR_UNICODE fields with format_text(); do so.

Bug: 1372
Change-Id: Ia32c3a92d220ac5174ecd25f33e2d1f85cfb8cb8
Reviewed-on: https://code.wireshark.org/review/34080
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2019-07-25 14:50:40 +00:00
Guy Harris 088b3d63a0 Remove the UTF-8 validation from proto_tree_add_string().
proto_tree_add_item() does no validation if ENC_UTF_8 is used as the
encoding, so there's no guarantee that the value of a string field is
valid UTF-8, and in some dissectors UTF-8 strings are fetched with other
mechanisms and then added with proto_tree_add_string().

We need to do some cleanup on string handling.

Bug: 15848
Change-Id: Ifc43111dbb47c478fa11280f2f771d90202499fa
Reviewed-on: https://code.wireshark.org/review/33677
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2019-06-20 00:34:18 +00:00
Guy Harris 9239ce6900 Don't check lenretval in proto_tree_add_item_ret_display_string_and_length().
It can't be null, and it must never be passed a null pointer.

Fixes Coverity CID 1445961.

Change-Id: Ifad962c51e23706fdc544326a45543fe11b73fd1
Reviewed-on: https://code.wireshark.org/review/33572
Tested-by: Petri Dish Buildbot
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2019-06-12 22:19:39 +00:00
Guy Harris 1c601c204a Have routines to add a protocol tree item and return a display string.
That way, even if we're not building a protocol tree, so that you don't
get protocol tree items, you can get the display string, e.g.  to use in
a column.

Replace the use of the "get display string" routines with calls to those
routines.

Change-Id: I23e3e88838bdf837d8660c271f78c79b7d1c5620
Reviewed-on: https://code.wireshark.org/review/33519
Petri-Dish: Guy Harris <guy@alum.mit.edu>
Tested-by: Petri Dish Buildbot
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2019-06-08 09:11:22 +00:00
Guy Harris ee35570e90 Improve handling of binary data that *might* be text.
Add a BASE_SHOW_ASCII_PRINTABLE flag for the "display" field, to use
with FT_BYTES and FT_UINT_BYTES fields; it specifies that, if the field
consists solely of printable ASCII characters, its value be displayed as
a string, in quotes.  Have a routine hfinfo_format_bytes() to do that
formatting, depending on the display field value.

Add routines to fetch the display value of string and
FT_BYTES/FT_UINT_BYTES fields; for strings, it's the result of
hfinfo_format_text(), and for byte arrays, it's the result of
hfinfo_format_bytes().

Use BASE_SHOW_ASCII_PRINTABLE for extended attribute data in SMB and
SMB2.  Use the routines in question for extended attribute names
(string) and data (bytes).  That keeps us from displaying non-text
extended attribute data as if it were text.

Document BASE_SHOW_ASCII_PRINTABLE.

Change-Id: I24dcf459c14f00985e4daaf9b58f5933964eabd8
Reviewed-on: https://code.wireshark.org/review/33517
Petri-Dish: Guy Harris <guy@alum.mit.edu>
Tested-by: Petri Dish Buildbot
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2019-06-07 21:15:23 +00:00
Guy Harris 1fd3003a6d "Zigbee" encoding is not a character encoding or an integer encoding.
It's a rule for interpretation of the length field of counted-string and
counted-octet-string fields.  This means it's 1) not a general rule for
interpreting integers and 2) not a character encoding, as it also
applies to octet strings and, even for character strings, it's
*orthogonal* to the character encoding.

Therefore, it should *not* be one of the character encoding values; it
should be a bit flag.

Make it so.  This means that

1) a character encoding can be specified for Zigbee Cluster Library
strings (they appear to have multiple character encodings possible);

2) the test of it that tested it as if it were a flag will no longer get
confused by character encodings that set one or more of the bits in the
old encoding value;

3) you don't have to special-case the encoding value passed to
get_uint_value().

Put in a comment emphasizing that values that aren't character encodings
should *not* be placed in the set of character encodings.

Change-Id: I8f50aaee8ca60b0781044287e9b38111de38c81f
Reviewed-on: https://code.wireshark.org/review/33341
Petri-Dish: Guy Harris <guy@alum.mit.edu>
Tested-by: Petri Dish Buildbot
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2019-05-24 21:26:16 +00:00
Dario Lombardo 91bbc58402 elastic: make fields all the same.
The outputs of -T ek and -G elastic-mapping don't match. To be effective
the fields in the mapping report and the fields in the traffic output must
be the same.

2 issues have been fixed. The elastic-mapping requires the parent protocol
to be prepended to the field to match the traffic output. The field "dns.a"
has been changed to "dns_dns_a".
The traffic output prints some fields with a leading "text_". This happens
for some fields that have been created under a text only field. One example
is "dns.a", that was printed as "text_dns_a". This has been fixed by accessing
the parent hfinfo resulting in "dns_dns_a" as other fields for the dns
protocol.

Bug: 15759
Change-Id: Ibd000c865102ca49bb6a6394019a475483eae4cc
Reviewed-on: https://code.wireshark.org/review/33099
Petri-Dish: Dario Lombardo <lomato@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Eneko Gómez <eneko.gomez.tecnalia@gmail.com>
Reviewed-by: Dario Lombardo <lomato@gmail.com>
2019-05-14 16:16:57 +00:00
Dario Lombardo ccf9820ea7 elastic: change 'pcap_file' into 'doc' in the mapping.
Newer versions of elastic are using 'doc' as type. Change the code
according to that.

Fix point (4) of the linked bug.

Bug: 15763
Change-Id: Ia28102a0914c6308eb3516daa57af2e49ce9a4e5
Reviewed-on: https://code.wireshark.org/review/33111
Petri-Dish: Dario Lombardo <lomato@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Eneko Gómez <eneko.gomez.tecnalia@gmail.com>
Reviewed-by: Dario Lombardo <lomato@gmail.com>
2019-05-13 17:25:15 +00:00
Dario Lombardo 719d8d6a81 elastic: change 'template' into 'index_patterns' in the mapping.
This is the new standard in recent Elastic versions.

Fix point (3) of the linked bug.

Bug: 15763
Change-Id: I64ef085c2a8ad9d25ced30a337287c8cb77903e4
Reviewed-on: https://code.wireshark.org/review/33112
Petri-Dish: Dario Lombardo <lomato@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Eneko Gómez <eneko.gomez.tecnalia@gmail.com>
Reviewed-by: Dario Lombardo <lomato@gmail.com>
2019-05-13 09:43:46 +00:00
Dario Lombardo ebcc9157c3 elastic: use correct elastic field types in mapping.
Elastic integer fields are:
integer: signed 32 bit
long: signed 64 bit

Fix values in mapping. uint64 is not handled by elastic, but still
mapped on 'long'.

Fix point (2) of the linked bug.

Bug: 15763
Change-Id: I14afa1cb7fcb6ad98d44707a8b506420e29ceb83
Reviewed-on: https://code.wireshark.org/review/33109
Petri-Dish: Dario Lombardo <lomato@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2019-05-13 07:22:38 +00:00
Dario Lombardo e5b4e673f0 proto: don't generate elastic-mapping entries for string fields.
The string type is the default in elasticsearch, then there is no
need to put those entries in the mapping report. This shortens a lot
the list.

Small indentation fix, while here.

Change-Id: If304d409a3ee2c30f24b5de4d90be522bbfae41e
Ping-Bug: 15719
Reviewed-on: https://code.wireshark.org/review/33053
Petri-Dish: Dario Lombardo <lomato@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
2019-05-03 21:35:29 +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
kanidef 496c4c53a3 add to get_time_value() case ENC_TIME_MSECS|ENC_LITTLE_ENDIAN:
Change-Id: I1fe2d38859d0523eb924784fc51eb3202479cdbb
Reviewed-on: https://code.wireshark.org/review/32664
Petri-Dish: Anders Broman <a.broman58@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2019-04-01 10:30:46 +00:00
Guy Harris 3267f3641f We need more pre-allocated fields.
Change-Id: I17affbd71b89d5fa9615ca1984ef6c38d21e8baf
Reviewed-on: https://code.wireshark.org/review/32345
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2019-03-07 03:32:00 +00:00
Uli Heilmeier 061ebbda56 Fixing some implicit coversations (-Wshorten-64-to-32)
Fixing some "implicit conversion loses integer precision" warnings
reported by clang with -Wshorten-64-to-32 option

Change-Id: Icd641d5f4fd8ff129f03f1b9e1da0fc86329f096
Reviewed-on: https://code.wireshark.org/review/31901
Petri-Dish: Anders Broman <a.broman58@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2019-02-08 12:12:18 +00:00
Peter Wu 03e13a6a9f wslua: fix memleaks related to Proto and Pref
Proto objects were only freed while reloading Lua plugins, be sure to
release these on program exit too. Fix missing deallocation of heur_list
(matches per-protocol cleanup in proto_cleanup_base).

Be sure to keep a reference to the "Pref" object after registering it to
a Proto, otherwise it could be garbage-collected early, resulting in
memleaks (because the preference was still in use).

Fixes a lot of memory leaks reported by ASAN for tests, ten tests were
affected by Proto_new leaks, four were affected by the new_pref leaks.

Change-Id: Ica52718849a33eda614775f533dc0fcefec9cc74
Reviewed-on: https://code.wireshark.org/review/31746
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
2019-01-27 09:43:05 +00:00
Dario Lombardo 82326d21fd proto: ensure valid width through assert.
Found by scan-build.

Change-Id: I467e56bfa4f20f5c87efa47823d54691503de318
Reviewed-on: https://code.wireshark.org/review/31486
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2019-01-13 07:12:43 +00:00
Dario Lombardo b67b47558d epan: remove redundant casts.
Found by clang-tidy.

Change-Id: Iaf6cf84c33b03ddfcd39a333b49f4987002afa56
Reviewed-on: https://code.wireshark.org/review/31338
Petri-Dish: Dario Lombardo <lomato@gmail.com>
Petri-Dish: Guy Harris <guy@alum.mit.edu>
Tested-by: Petri Dish Buildbot
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2019-01-03 23:39:43 +00:00
Dario Lombardo 4160f1017f proto: make ws_type_to_elastic static.
Change-Id: I15d1075a1447a6f550d600f765e6abc8dae862ad
Reviewed-on: https://code.wireshark.org/review/30972
Petri-Dish: Dario Lombardo <lomato@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Michael Mann <mmann78@netscape.net>
2018-12-09 03:04:00 +00:00
Peter Wu 656cc19fc7 Replace JSON-GLib by custom JSON dumper library
The (optional) JSON-GLib library adds dependencies on GObject, GIO. For
statically linked oss-fuzz builds it also adds libffi and more. To avoid
these dependencies, replace JSON-GLib by some custom code. This allows
`tshark -G elastic-mapping` to be enabled by default without extra deps.

API design goals of the new JSON dumper library:

- Small interface without a lot of abstraction.
- Avoid memory allocations if possible (currently none, but maybe
  json_puts_string will be replaced to improve UTF-8 support).
- Do not implement parsing, this is currently handled by jsmn.

Methods to open/close array/objects and to set members are inspired by
the JsonGlib interface. The interfaces to write values is inspired by
the sharkd code (json_puts_string is also borrowed from that).

The only observed differences in the tshark output:
- JSON-GLib ignores duplicates, json_dumper does not and may produce
  duplicates and currently print two "ip.opt.sec_prot_auth_unassigned".
- JSON-GLib adds a space before a colon (unimportant formatting detail).
- (Not observed, but UTF-8 strings will be wrong like bug 14948.)

A test was added to catch changes in the tshark output. I also fuzzed
json_dumper with libFuzzer + UBSAN/ASAN and fixed an off-by-one error.

Change-Id: I0c85b18777b04d1e0f613a3d59935ec59be87ff4
Link: https://www.wireshark.org/lists/wireshark-dev/201811/msg00052.html
Reviewed-on: https://code.wireshark.org/review/30732
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-11-20 05:03:56 +00:00
Pascal Quantin a4bbb45d52 proto.c: increase the number of pre allocated fields
Change-Id: I5b2cb3ae6a9e6ab507f18e6eb5f89a37b2983129
Reviewed-on: https://code.wireshark.org/review/30551
Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
2018-11-08 22:08:09 +00:00
Pascal Quantin a99bba4c7c Fix "Follow TLS Stream" after ssl -> tls rename
Change-Id: I53be2ae6fae135b2da98ae95deac535bcd37af74
Reviewed-on: https://code.wireshark.org/review/30473
Petri-Dish: Pascal Quantin <pascal.quantin@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
2018-11-01 17:09:33 +00:00
Pascal Quantin 4a5812aca2 Revert "FT_BYTES: fix dissection of FT_BYTES when using SEP_SPACE and "NONE" options"
This reverts commit 0457e60419.

Change-Id: Id39722872efbe98648754d7543da7ae5b08f8b67
Reviewed-on: https://code.wireshark.org/review/30451
Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
2018-11-01 07:49:02 +00:00
Jeremy Martin 0457e60419 FT_BYTES: fix dissection of FT_BYTES when using SEP_SPACE and "NONE" options
SEP_SPACE and BASE_NONE both default to colon (:).  Fix SEP_SPACE and add SEP_NONE

Bug: 15253
Change-Id: Ib5db997714414370b08ffb9458c73d4aeef6aacf
Reviewed-on: https://code.wireshark.org/review/30447
Reviewed-by: Jeremy Martin <boardermartin@gmail.com>
Petri-Dish: Anders Broman <a.broman58@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-11-01 06:25:31 +00:00
Tom Hughes 076f941bc9 IAX: Use extended 64 bit value to string matching for codecs
Change-Id: I23fe00594296dd29b456804043b6302bd0219884
Reviewed-on: https://code.wireshark.org/review/30394
Petri-Dish: Pascal Quantin <pascal.quantin@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
2018-10-27 14:46:06 +00:00
Tom Hughes 99c62bf797 Add support for extended 64 bit value to string matching
This adds val64_string_ext to parallel value_string_ext in the
same way that val64_string parallels value_string.

Change-Id: Iadbfc49f5a4540000ed92fd0469e8d273911e97e
Reviewed-on: https://code.wireshark.org/review/30385
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-10-27 05:34:59 +00:00
AndersBroman a4662f86bb proto.c: Add hint to an assert.
Change-Id: I0204cb38f66363a5d8634d69abe7a2d7d7ebe631
Reviewed-on: https://code.wireshark.org/review/30257
Petri-Dish: Anders Broman <a.broman58@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-10-19 08:26:18 +00:00
Richard Sharpe 6eba988f7c wslua: Add support for base.RANGE_STRING handling.
A range string is passed as a table of tables, eg:

  range_string = {
     { 0, 24, "Some string for values 0 to 24" },
     { 25, 25, "The string for value 25" },
     { 26, 255, "The string for the remainder" }
  }

Included is a minimal Lua test for range strings and value strings
(which did not have one previously.) It will take more time than I
currently have to figure out how to do a more exhaustive test.

Also fixed some grammar issues in error messages along the way.

Change-Id: Ia9d1efc8adabb6528c4bdcf1624c9ede49e2fdc6
Reviewed-on: https://code.wireshark.org/review/30211
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Reviewed-by: Richard Sharpe <realrichardsharpe@gmail.com>
2018-10-17 20:08:57 +00:00
Gerald Combs 8f08a4e74e Try to discourage the use of APIs via counting.
Add the ability to specify maximum function counts for each group to
checkAPIs. Add maximum counts for the "termoutput" and "abort" groups
where needed. Show summaries in various checkAPI targets.

Switch uses of ws_g_warning back to plain g_warning.

Change-Id: I5cbddc8c671729e424eed8551f69116d16491976
Reviewed-on: https://code.wireshark.org/review/29721
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
2018-09-19 16:07:03 +00:00
AndersBroman 23118f7164 proto.c: Increase number of preallocted fields to 205000
Change-Id: Id0590e5c860697a4a70278cec6ec8231203ab40b
Reviewed-on: https://code.wireshark.org/review/29552
Petri-Dish: Anders Broman <a.broman58@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-09-10 12:55:12 +00:00
Stig Bjørlykke a1ae40f1a3 proto: Reset handled occurrences counter
Reset handled occurrences counter between each multi field custom
column to be able to handle configurations with occurrence set.

Change-Id: Iaa01da069b661ddbb2871370fcc9f9fde33041bb
Reviewed-on: https://code.wireshark.org/review/29427
Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org>
Tested-by: Petri Dish Buildbot
Reviewed-by: Stig Bjørlykke <stig@bjorlykke.org>
2018-09-05 13:43:05 +00:00
Stig Bjørlykke 38657fad58 epan: Restrict detect trailing stray characters in strings
Only detect trailing string characters in FT_STRING, FT_STRINGZ and
FT_STRINGZPAD, and when ENC_ASCII or ENC_UTF_8 (for now).

Support for checking other encodings can be added later.

Bug: 15105
Change-Id: Ib7b61f65e4f99f85998937e843ad5312c6b03a28
Reviewed-on: https://code.wireshark.org/review/29411
Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org>
Tested-by: Petri Dish Buildbot
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
Reviewed-by: Stig Bjørlykke <stig@bjorlykke.org>
2018-09-04 17:42:50 +00:00
Gerald Combs ef01359849 Add support for protocol aliases. Switch BOOTP to DHCP.
Add support for aliasing one protocol name to another and for filtering
using aliased fields. Mark aliased fields as deprecated.

Rename the BOOTP dissector to DHCP and alias "bootp" to "dhcp". This
lets you use both "dhcp.type" and "bootp.type" as display filter fields
without having to duplicate all 500+ DHCP/BOOTP fields.

To do:
- Add checks to proto.c:check_valid_filter_name_or_fail?
- Transition SSL to TLS.
- Rename packet-bootp.c to packet-dhcp.c?

Change-Id: I29977859995e8347d80b8e83f1618db441b10279
Ping-Bug: 14922
Reviewed-on: https://code.wireshark.org/review/29327
Reviewed-by: Gerald Combs <gerald@wireshark.org>
Petri-Dish: Gerald Combs <gerald@wireshark.org>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-08-31 05:25:17 +00:00
Stig Bjørlykke 5c36f6166c epan: Detect trailing stray characters in strings
Trailing stray characters will not show up in the packet tree item
when the string is correctly null terminated. This expert info
will indicate when this occurs, typically from wrongly implemented
protocol encoders.

This will warn about cases like:

  tvb = "foo\0bar"
  proto_tree_add_item(..., tvb, 0, 7, ...)

Change-Id: I66b9d3ba7bb3e45f1f6e492fa6916b29c9ee9ca4
Reviewed-on: https://code.wireshark.org/review/29310
Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-08-31 05:22:09 +00:00
João Valverde 8eddb1650d epan: Remove unnecessary all protocols registration callback
We are exporting a registration function from libwireshark just
to have it passed back as a callback. Seems unnecessary.

Change-Id: I7621005c9be11691d319102326824c5e3520a6f3
Reviewed-on: https://code.wireshark.org/review/29328
Petri-Dish: João Valverde <j@v6e.pt>
Tested-by: Petri Dish Buildbot
Reviewed-by: João Valverde <j@v6e.pt>
2018-08-29 23:22:44 +00:00
João Valverde 9d9a873d9a Make AT_VINES a built-in type
Change-Id: I5c11cf4c7bee1b2b7072a6a0db5344a6b8a569ac
Reviewed-on: https://code.wireshark.org/review/29326
Petri-Dish: João Valverde <j@v6e.pt>
Tested-by: Petri Dish Buildbot
Reviewed-by: João Valverde <j@v6e.pt>
2018-08-29 19:36:43 +00:00
João Valverde e928a866f9 Increase PROTO_PRE_ALLOC_HF_FIELDS_MEM
Required to pass the test suite.

28: Process output for suite_unittests.case_unittests.test_unit_fieldcount:
28: -- Begin stdout for command ('run/tshark', '-G', 'fieldcount') --
28: There are 205013 header fields registered, of which:
28: 	0 are deregistered
28: 	2468 are protocols
28: 	15147 have the same name as another field
28:
28: 205000 fields were pre-allocated.
28: * * Please increase PROTO_PRE_ALLOC_HF_FIELDS_MEM (in epan/proto.c)! * *
28:
28: The header field table consumes 1609 KiB of memory.
28: The fields themselves consume 14414 KiB of memory.
28: -- End stdout for command ('run/tshark', '-G', 'fieldcount') --
28: -- Begin stderr for command ('run/tshark', '-G', 'fieldcount') --
28: -- End stderr for command ('run/tshark', '-G', 'fieldcount') --
28/29 Test #28: suite_unittests .....................***Failed   12.72 sec

Change-Id: I694ed42dbd5bef99df9d2037d505d71901afd2dd
Reviewed-on: https://code.wireshark.org/review/29209
Reviewed-by: João Valverde <j@v6e.pt>
2018-08-20 23:12:28 +00:00
Pascal Quantin 28b7adfadc proto.c: allow more field types for proto_tree_add_item_ret_uint64()
Let's make the function accept FT_UINT40, FT_UINT48 and FT_UINT56 types.

Ping-Bug: 15050
Change-Id: I35440a7c0b9cbf25bd8d903c425b6026d6a987f0
Reviewed-on: https://code.wireshark.org/review/29044
Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
2018-08-09 15:18:06 +00:00
Guy Harris 118017e3e2 Supply a 0s/0ns value for invalid time value lengths.
Other routines that fetch values and can report a type/length error
without throwing an exception return a value, even if it's not the
appropriate value (as there is no appropriate value); make
get_time_value() do the same.

Ideally, we'd mark the protocol tree item, and the value, as being
invalid, and treat invalid values specially, but that's a bigger change
that would involve significantly more mucking about in the innards of
epan/proto.c as well as in code that looks at the protocol tree and at
field values, as well as deciding what the appropriate thing to do is
with a field with no value when, for example, -T {fields,pdml,json,ek,etc.}
is used.

Bug: 14957
Change-Id: Iab91198e560f52809d989cfce8b51b1b027cff73
Reviewed-on: https://code.wireshark.org/review/28722
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2018-07-16 04:17:26 +00:00
Guy Harris 1075054a10 Add new encoding names for seconds/{micro,nano}second time stamps.
Add ENC_TIME_SECS_NSECS and ENC_TIME_SECS_USECS; they make it more
explicit (especially to those not familiar with UN*X data types) what
the representation is, allow for ENC_TIME_SECS_MSECS etc. if they're
needed, and match names such as ENC_TIME_SECS and ENC_TIME_MSECS.

Change-Id: I6ab36fb4da70563587141cd65ffff8523477b0c4
Reviewed-on: https://code.wireshark.org/review/28564
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2018-07-02 04:09:21 +00:00
Guy Harris 3a9b055f04 Add support for 8+8 and 8+4 struct timespec, and use it with 9P.
Add support for 8-byte-seconds/8-byte-nanoseconds and 8-byte-seconds/
4-byte-nanoseconds time values.  Use them in the 9P dissector, with
proto_tree_add_item().

Only do the length validity checking for time values in
get_time_value().

Change-Id: I0f1d791d7aa503093a491d2c33300bd55ca7866e
Reviewed-on: https://code.wireshark.org/review/28560
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2018-07-02 01:11:16 +00:00
Guy Harris 0fbb5f84d0 Do bounds checking of the offset and length in proto_tree_add_string().
Throw an exception if they don't correspond to data available in the
packet - and do so even if the protocol tree argument is null, so that
we catch very long strings that could cause the offset to overflow.

Ask why we try to handle a null pointer passed as the string argument,
while we're at it.

Bug: 14738
Change-Id: I2fa79ad0dcd1f41608844a573e045197ac60aa62
Reviewed-on: https://code.wireshark.org/review/28179
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2018-06-10 01:12:31 +00:00
Stig Bjørlykke 5767118ec9 Free dynamic header fields on exit
Put routine to free all dynamically registered header fields in the
UAT reset callback to avoid ASAN report for memory leaks on exit.

Handle duplicated entries without leaking memory.

Call proto_free_deregistered_fields() in proto_cleanup() and move
this after prefs_cleanup() to free the memory used in UATs.

Change-Id: I96545177b5b23b9c20ad8e7751a0d5621c9ca10f
Reviewed-on: https://code.wireshark.org/review/27907
Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org>
Tested-by: Petri Dish Buildbot
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
2018-06-03 20:18:05 +00:00
Guy Harris 2439483593 Indicate *which* field would go past the MAX_TREE_ITEMS limit.
That could help find the problem if all we have is the error message, as
it'd at least indicate where the problem is occurring.

Change-Id: I01154ff62088a4b710c131cb153e8e4593ebc3b2
Reviewed-on: https://code.wireshark.org/review/27878
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2018-05-28 18:37:56 +00:00
Guy Harris 0f1f1d0ab8 Creat protocol tvbuff before allocating and freeing memory.
That way, if the attempt to create the protocol tvbuff throws an
exception, we won't leak the protocol representation string, as we won't
even try to allocate it.

Bug: 14719
Change-Id: Id2855bc97e71aa0682737d1a04486a2a01f5f1e6
Reviewed-on: https://code.wireshark.org/review/27730
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2018-05-23 03:43:08 +00:00
Joakim Karlsson 51062de5ec proto: add handle of NTP bit 0
According to RFC2030, chapter 3.

If bit 0 is set, the UTC time is in the range 1968-2036 and
UTC time is reckoned from 0h 0m 0s UTC on 1 January 1900.
If bit 0 is not set, the time is in the range 2036-2104 and
UTC time is reckoned from 6h 28m 16s UTC on 7 February 2036.

Change-Id: I9cf25449a1cb3c12d5514e3c7820a204525589d6
Reviewed-on: https://code.wireshark.org/review/27553
Petri-Dish: Anders Broman <a.broman58@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-05-22 04:26:18 +00:00
Pascal Quantin 40dbc0ccf2 proto.c: do not dereference a NULL pointer in proto_item_get_len() on first pass
Like the proto_item_set_XXX functions, check proto_item pointer validity
before using it. It can be NULL on first pass for example.

Bug: 14703
Change-Id: I94957e0738d66f99793682dc0ea1c7c0a65ceecd
Reviewed-on: https://code.wireshark.org/review/27629
Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
Petri-Dish: Pascal Quantin <pascal.quantin@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-05-18 09:19:12 +00:00
Peter Wu bb81e1807b Free g_ptr_array_free-related memory leaks
g_ptr_array_free(a, FALSE) returns "a->pdata". Callers that do not
handle this will leak memory (e.g. "tshark -G plugins"). Convert other
users to use the return value instead of direct access to "a->pdata".

Change-Id: I29835477d587f5f54bf0d94cdae9f375e3da3ce3
Reviewed-on: https://code.wireshark.org/review/27437
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
2018-05-14 13:42:10 +00:00
Dylan Ulis d80dbe533c Display configured checksum Expert summary string
Previously, checksum code would override the expert_field summary
string configured by dissectors, and display the generic "Bad checksum"
string in the Expert Information dialog.

This change uses the configured expert_field summary string instead.
eg: "CRC-S1 incorrect [should be 0xff]" instead of "Bad checksum [should
be 0xff]"

This fixes problem #2 in the linked bug.

Bug: 14425
Change-Id: I168b2be92ec2d8d6f956beeaf6292574bc1d9dab
Reviewed-on: https://code.wireshark.org/review/25758
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-05-14 08:15:39 +00:00
Peter Wu 19c4589246 proto: handle split bits covering more than 32 bits
proto_tree_add_split_bits_item_ret_val can handle bits from an arbitrary
sized buffer, as long as it covers no more than 64 bits. If the
octet-aligned mask covers up to 32 bits, then this mask is also shown.
If this mask was larger than 64 bits, then undefined behavior could
occur, so check for that.

For larger masks, instead of "= GmPRS Terminal Type: Unknown (96)",
display "7 bits = GmPRS Terminal Type: Unknown (96)" instead.

Bug: 13613
Change-Id: I111cf6a0705f999e42d83bfe57ac84f414946d0b
Link: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=1158
Reviewed-on: https://code.wireshark.org/review/27517
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-05-14 08:13:47 +00:00
Dario Lombardo 4b6224a673 proto: don't overrun buffer.
This is shown by a bunch of coverity reports all pointing at this line.
Every buffer has a ITEM_LABEL_LENGTH, but label_mark_truncated access it
at ITEM_LABEL_LENGTH (off-by-one).

CIDs:
1435461
1435462
1435465
1435466
1435471
1435472
1435477
1435481
1435483
1435484
1435485
1435489
1435492
1435500

Fixes: v1.11.3-rc1-1837-gf94674d2fb ("truncate UTF-8 strings only at the boundary between two characters")
Change-Id: I3781c36594f7db880bc9f76b64d261dbc498c0ce
Reviewed-on: https://code.wireshark.org/review/27425
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot
Reviewed-by: Dario Lombardo <lomato@gmail.com>
2018-05-09 12:29:15 +00:00
Joerg Mayer c9832726bf Refer to the bytes of the real checksum field if the checksum is missing or generated
Change-Id: I6c7a5b1441b97604d2847f7b74abc7a9c9e98d2c
Reviewed-on: https://code.wireshark.org/review/27381
Reviewed-by: Jörg Mayer <jmayer@loplof.de>
2018-05-07 13:22:23 +00:00
Peter Wu f9522d8a23 Qt: fix crash on dragging in packet dialog
"packet_dialog.cpp" does not use setCaptureFile, resulting in a NULL
dereference while trying to obtain the dissection context. Apply a fix
similar to v2.5.1rc0-121-g9198448f9d (pass a fixed dissection context to
ProtoTree). Additionally, fix a memleak and correct documentation.

Why not add "proto_tree_->setCaptureFile(cap_file_.capFile())" in
PacketDialog? Well, it also uses "proto_tree_->setRootNode(edt_.tree)"
which means that "cf_->edt" would be different from "edt_". If that is
the case, then "proto_construct_match_selected_string" will not return a
filter for FT_NONE fields (see the call chain in proto.c).

Bug: 14620
Change-Id: I6eeaf32b650a2095e15f64bbe64b54cdd545c7a9
Fixes: v2.5.0rc0-1608-g4d6454e180 ("Qt: Drag n Drop Filter expression from Packet Tree")
Reviewed-on: https://code.wireshark.org/review/27160
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Reviewed-by: Roland Knall <rknall@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
2018-04-26 16:41:34 +00:00
Dario Lombardo fc6b8ab698 tshark: improve -G elastic-mapping command by adding filters.
The generated elastic mapping file is huge and it can hassle softwares
like Kibana. This change adds the ability to append desired filters
that will appear in the mapping file.

This change adds the option --elastic-mapping-filter <protocols> to tshark.

Example: tshark -G elastic-mapping --elastic-mapping-filter ip,udp,dns

make only those 3 protocols to appear in the mapping file.

Change-Id: Ie2dcd6e44be2d084e8e50cd6554bd90178da4e38
Reviewed-on: https://code.wireshark.org/review/27001
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot
Reviewed-by: Dario Lombardo <lomato@gmail.com>
2018-04-19 15:54:47 +00:00
Dario Lombardo f545cc5321 proto: use json_node_free instead of json_node_unref.
The latter is present in recent versions only.

Change-Id: I1da84ff0ba93ee4a3725163f0ed3a745466e201b
Reviewed-on: https://code.wireshark.org/review/27024
Petri-Dish: Dario Lombardo <lomato@gmail.com>
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot
Reviewed-by: Dario Lombardo <lomato@gmail.com>
2018-04-19 11:55:38 +00:00
Dario Lombardo 511c2e166a tshark: add -G elastic-mapping report.
This option generates an ElasticSearch mapping file as described here:
https://www.elastic.co/blog/analyzing-network-packets-with-wireshark-elasticsearch-and-kibana

It leverages the Glib-json library.

Change-Id: Iff25f991e87d3da07bf06654e353fb785799dde9
Reviewed-on: https://code.wireshark.org/review/26848
Petri-Dish: Dario Lombardo <lomato@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
Reviewed-by: Dario Lombardo <lomato@gmail.com>
2018-04-18 08:57:39 +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
Peter Wu ccff21854d Forbid leading, duplicated and trailing dots in field names
In order to simplify the display filter scanner, try to restrict the use
of dots ('.') in field names. Forbid leading dots, does not affect
current dissectors. Fix '..' typo in fpp dissector and forbid it. Forbid
trailing dots after fixing dissectors: some of them just have an excess
dot, others are missing a name after the dot.

Change-Id: I6e58a04ef0306ee8c16fbf6a3cabb076d7fc69c9
Reviewed-on: https://code.wireshark.org/review/26967
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-04-16 15:44:08 +00:00
Guy Harris c7970d9356 Add, and use, "fetch signed value" for lengths < 40 bits.
Add 8-bit, 16-bit, 24-bit, and 32-bit "fetch signed value" routines, and
use them rather than casting the result of the 8/16/24/32-bit "fetch
unsigned value" routines to a signed type (which, BTW, isn't sufficient
for 24-bit values, so this appears to fix a bug
in epan/dissectors/packet-zbee-zcl.c).

Use numbers rather than sizeof()s in various tvb_get_ routines.

Change-Id: I0e48a57fac9f70fe42de815c3fa915f1592548bd
Reviewed-on: https://code.wireshark.org/review/26844
Petri-Dish: Guy Harris <guy@alum.mit.edu>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-04-10 14:55:45 +00:00
Guy Harris b4b66d1b94 Increase PROTO_PRE_ALLOC_HF_FIELDS_MEM.
Change-Id: I8d294d7ee4b37586ffe5aff982fe3a016b594c1d
Reviewed-on: https://code.wireshark.org/review/26780
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2018-04-06 17:37:46 +00:00
Guy Harris 494508f2d0 Clean up REPORT_DISSECTOR_BUG().
Have it take a format and argument list as arguments, and have the
formatting done inside the reporting code.  That way, we're not relying
on any particular wmem scope working.

If WIRESHARK_ABORT_ON_DISSECTOR_BUG is set, try to add the message to
the crash information (currently only supported in macOS), and print it
to the standard error, before crashing.  We won't necessarily have a
usable crash dump to analyze, so we can't rely on that to find the cause
of the crash.

Ping-Bug: 14490
Change-Id: I2b39169c45c84f2ada31efa1d413bd28c140f8f4
Reviewed-on: https://code.wireshark.org/review/26643
Petri-Dish: Guy Harris <guy@alum.mit.edu>
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2018-03-25 23:49:35 +00:00
Guy Harris 6a75c59a22 Fix whitespace.
Change-Id: I565969aa18628a635c2471da56c43cf2689c44d5
Reviewed-on: https://code.wireshark.org/review/26640
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2018-03-25 20:37:04 +00:00
Guy Harris 5bfacbfa89 Give a better error message.
DISSECTOR_ASSERT_NOT_REACHED() doesn't say *why* the code in question
was reached; it's better to give a more explicit error message.

Change-Id: I88b930e5a90ba8692aeac6ee29fa8fda21b5067b
Reviewed-on: https://code.wireshark.org/review/26639
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2018-03-25 20:32:20 +00:00
Guy Harris ea0b580b97 Fix a check.
Presumably the intent is to check for unsigned integer and signed
integer types, not to check twice for unsigned integer types.

Thanks and a tip of the Hatlo hat to Visual Studio Code Analyzer for
finding this.

Change-Id: Ie8e4d231af929ee8e626c5c9258c3356d5209f4f
Reviewed-on: https://code.wireshark.org/review/26187
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2018-02-28 20:08:41 +00:00
Alexis La Goutte a35592eb20 proto(.c): remove extra bracket
Change-Id: Iccf76c35be36e0e806d8878b93902d6984a815da
Reviewed-on: https://code.wireshark.org/review/26102
Petri-Dish: Alexis La Goutte <alexis.lagoutte@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-02-25 21:12:34 +00:00
Guy Harris 238550b9c5 Make some arguments const, and remove casting-away of constness.
Change-Id: Iaa43b4b355179a265975f67952feac819e79f7a6
Reviewed-on: https://code.wireshark.org/review/25957
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2018-02-21 05:34:52 +00:00
Guy Harris a82621eecb FT_FLOAT and FT_DOUBLE support BASE_UNIT_STRING, too.
Handle them in free_deregistered_field() and
proto_registrar_dump_values().

Change-Id: I38c7b440adc46e32dde8bd629e58535baac9dd6d
Reviewed-on: https://code.wireshark.org/review/25916
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2018-02-20 06:22:39 +00:00
Dario Lombardo 8cd389e161 replace SPDX identifier GPL-2.0+ with GPL-2.0-or-later.
The first is deprecated, as per https://spdx.org/licenses/.

Change-Id: I8e21e1d32d09b8b94b93a2dc9fbdde5ffeba6bed
Reviewed-on: https://code.wireshark.org/review/25661
Petri-Dish: Anders Broman <a.broman58@gmail.com>
Petri-Dish: Dario Lombardo <lomato@gmail.com>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-02-08 14:57:36 +00:00
Graham Bloice 5cb7a729d3 Increase PROTO_PRE_ALLOC_HF_FIELDS_MEM
We've added more fields, increment the pre-allocation amount.

Change-Id: Ia5f1aab7a2fa120049162d17a63f99bf21a3fe37
Reviewed-on: https://code.wireshark.org/review/25566
Reviewed-by: Graham Bloice <graham.bloice@trihedral.com>
Petri-Dish: Graham Bloice <graham.bloice@trihedral.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Michael Mann <mmann78@netscape.net>
2018-02-02 14:56:22 +00:00
Michael Mann 954fd253e4 Add duplicate value_string in check filter
Change-Id: Ie00d057f5bc36d65b6bba790169543a65b068e47
Signed-off-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
Reviewed-on: https://code.wireshark.org/review/20744
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-01-24 11:48:53 +00:00
Stig Bjørlykke 4e87f6c01a proto: Small code cleanup in proto_register_protocol
- Remove unneeded assignments
- Fix some comments and whitespace

Change-Id: I79de66315db29fe7c59fc18f3b3b464ac55121c8
Reviewed-on: https://code.wireshark.org/review/25221
Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-01-09 13:07:32 +00:00
Graham Bloice 5f24a78113 Increase PROTO_PRE_ALLOC_HF_FIELDS_MEM
We've added more fields, increment the pre-allocation amount

Change-Id: If0e68697c797e8709349a59b86fbcd4397730476
Reviewed-on: https://code.wireshark.org/review/25220
Reviewed-by: Graham Bloice <graham.bloice@trihedral.com>
Petri-Dish: Graham Bloice <graham.bloice@trihedral.com>
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-01-09 11:52:12 +00:00
Alexis La Goutte 0bde3e96f0 Add ENC_VARINT_QUIC
Used to support variable length in QUIC protocol

Bug: 13881
Change-Id: Ia274b1530152376c5fb4e364fc4cf5ab246be1b3
Reviewed-on: https://code.wireshark.org/review/24990
Petri-Dish: Alexis La Goutte <alexis.lagoutte@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Craig Jackson <cejackson51@gmail.com>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-01-02 05:29:39 +00:00
Michael Mann 0d6eb9631f Convert Enabled protocols dialog to use model.
Change-Id: I618df2f2608adcd1be5da02262c5296e4d86cfba
Reviewed-on: https://code.wireshark.org/review/24866
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot
Reviewed-by: Roland Knall <rknall@gmail.com>
2017-12-19 08:21:19 +00:00
Gerald Combs 3c87991c28 -1 is a valid tree_type value.
Adjust tree_expanded and FieldInformation::treeType accordingly.

Change-Id: I9b12c28550ba2639f636531a7ea1841df0638b5e
Reviewed-on: https://code.wireshark.org/review/24844
Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2017-12-18 04:28:06 +00:00
Stig Bjørlykke 774a986ec0 epan: Add default type handling for custom column
Add default type handling in proto_custom_set() to prevent crashes when
trying to use FT_IPXNET, FT_AX25 or FT_VINES items as custom columns.

This will also work as a safeguard when adding new types.

Change-Id: Iaf3b48aec72f0e5c10332b0e6d5f7221b0196e15
Reviewed-on: https://code.wireshark.org/review/24836
Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2017-12-15 20:59:04 +00:00
Stig Bjørlykke 1651371d17 epan: Whitespace fixes
Change-Id: I859c7bf5cfaf23b46d2cda7ff9c7e1ddd164832a
Reviewed-on: https://code.wireshark.org/review/24838
Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2017-12-15 18:57:28 +00:00
João Valverde cebb8ea20e Add new plugin type for libwireshark
Allow epan itself to be extended by plugins. Adds the following new plugin
interfaces:

  void plugin_epan_init()
  void plugin_epan_dissect_init(epan_dissect_t *)
  void plugin_epan_dissect_cleanup(epan_dissect_t *)
  void plugin_epan_cleanup()
  void plugin_epan_register_all_protocols(register_cb, gointer) [OPTIONAL]
  void plugin_epan_register_all_handoffs(register_cb, gointer) [OPTIONAL]

Any one of these can be an empty function but the first four must be
present.

The motivation for the change is a better way to implement a language binding
other than registering a fake protocol and stuffing everything into a single
dissector call (and maybe require an extra packet_info field) but I expect
there would be other interesting use cases.

Change-Id: I215d50750ac7561fe25fdcdcfbc6a3f351984785
Reviewed-on: https://code.wireshark.org/review/24813
Petri-Dish: João Valverde <j@v6e.pt>
Tested-by: Petri Dish Buildbot
Reviewed-by: João Valverde <j@v6e.pt>
2017-12-14 22:12:38 +00:00
João Valverde 995812c5f1 Refactor plugin registration and loading
Put different types of plugins (libwiretap, libwireshark) in different
subdirectories, give libwiretap and libwireshark init routines that
load the plugins, and have them scan the appropriate subdirectories
so that we don't even *try* to, for example, load libwireshark plugins
in programs that only use libwiretap.

Compiled plugins are stored in subfolders of the plugin folders, with
the subfolder name being the Wireshark minor version number (X.Y). There is
another hierarchical level for each Wireshark library (libwireshark, libwscodecs
and libwiretap).

The folder names are respectively plugins/X.Y/{epan,codecs,wiretap}.

Currently we only distribute "epan" (libwireshark) plugins.

Change-Id: I3438787a6f45820d64ba4ca91cbe3c8864708acb
Reviewed-on: https://code.wireshark.org/review/23983
Petri-Dish: João Valverde <j@v6e.pt>
Tested-by: Petri Dish Buildbot
Reviewed-by: João Valverde <j@v6e.pt>
2017-12-14 08:43:57 +00:00
Stig Bjørlykke e4750105b2 epan: Show a check mark in custom columns for FT_NONE types
This is valuable when adding a expert info field as custom column,
but will also make sense for other FT_NONE types.

Change-Id: Ib1a14c59a5450f2e713f190aecf3484586d116c4
Reviewed-on: https://code.wireshark.org/review/24787
Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org>
Tested-by: Petri Dish Buildbot
Reviewed-by: Stig Bjørlykke <stig@bjorlykke.org>
2017-12-13 10:00:29 +00:00
Stig Bjørlykke 158d929884 epan: Use check mark in protocol custom column
Change from the text "Yes" to a utf8 check mark to indicate the
precense of a protocol in custom columns.

Change-Id: I9510333fc12148bf1f61aa2ddea2c6d390a9491a
Reviewed-on: https://code.wireshark.org/review/24783
Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org>
Tested-by: Petri Dish Buildbot
Reviewed-by: Stig Bjørlykke <stig@bjorlykke.org>
2017-12-12 22:36:20 +00:00
Michael Mann 2f2c2b06e2 Add Zigbee encoding, ENC_ZIGBEE
Add the "special handling" of length = 0xFF for single byte or 0xFFFF
for uint16 value means size of field to follow is 0.

Ping-Bug: 14138
Change-Id: I0baa40f63152b9420a6569ca6cc5eba638fbc790
Reviewed-on: https://code.wireshark.org/review/24428
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot
Reviewed-by: Craig Jackson <cejackson51@gmail.com>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2017-11-22 09:10:05 +00:00
Pascal Quantin f8a1878202 proto.c: fix field display test in hfinfo_number_value_format_display64()
While we are at it, let's use the FIELD_DISPLAY() macro everywhere.

Bug: 14169
Change-Id: I685cb7eb4b9c52f836762c92baeb636570a6d12f
Reviewed-on: https://code.wireshark.org/review/24285
Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
Petri-Dish: Pascal Quantin <pascal.quantin@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Richard Sharpe <realrichardsharpe@gmail.com>
2017-11-08 06:59:40 +00:00
Guy Harris 4405c5d769 Fix white space.
Change-Id: I8a50391dcfb113c251f24f64486828d5d8a1d0c0
Reviewed-on: https://code.wireshark.org/review/24260
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-11-06 21:27:14 +00:00
João Valverde ba6dd97081 Remove epan win32 x86 assembly
Not used. Remove also weird pre-hash hash optimization in proto.c.

Change-Id: Ibebc12dbe90ac1d05fb1ba601d32fe98797fbd56
Reviewed-on: https://code.wireshark.org/review/24254
Reviewed-by: Michael Mann <mmann78@netscape.net>
Reviewed-by: João Valverde <j@v6e.pt>
Petri-Dish: João Valverde <j@v6e.pt>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2017-11-05 23:20:20 +00:00
Guy Harris dd1c18dd03 Make FT_IPv4 a bit more like FT_IPv6.
FT_IPv6 doesn't expose the prefix, which is used only for values in
filter expressions, not values in protocol fields; do the same for
FT_IPv4, hiding the netmask, and using fvalue_get_integer() to get the
value, having it return a network-byte-order value for the address.

(This also makes it opaque whether the address and netmask are stored in
host or network byte order.)

Change-Id: I4285a87f6ccef2c0ccec040490ddcd15d787326e
Reviewed-on: https://code.wireshark.org/review/24177
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-10-30 01:40:13 +00:00
Guy Harris 734c5b35a5 Get rid of ipv4_get_net_order_addr() and ipv4_get_host_order_addr().
Just directly use the addr field, converting from host to network byte
order if necessary.

Change-Id: Ie1cd9ea5527b7824014dc315225ad2a6adb61c38
Reviewed-on: https://code.wireshark.org/review/24176
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-10-30 00:50:06 +00:00
Guy Harris 695d8fc318 MOAR PRE-ALLOCATED FIELDS.
Do what the errors in the master buildbots say to do.

Change-Id: I2b926bd9a75a1490390c42b8080f29e48096a3b4
Reviewed-on: https://code.wireshark.org/review/24143
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-10-28 05:25:46 +00:00
Pascal Quantin e82adfba74 proto.c: do not set an item length longer that the remaining tvb length
Ping-Bug: 14128
Change-Id: Iae5cb2f85d5d2fa3f2b6051aa57390a3f73d724a
Reviewed-on: https://code.wireshark.org/review/24087
Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
Petri-Dish: Pascal Quantin <pascal.quantin@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Michael Mann <mmann78@netscape.net>
2017-10-26 23:37:51 +00:00
Pascal Quantin ed20250c13 proto.c: protect against buffer overflow in proto_find_undecoded_data()
Bug: 14128
Change-Id: I01aadf2dc9a3f714caaef273a7e012c6f1840726
Reviewed-on: https://code.wireshark.org/review/24088
Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
Petri-Dish: Pascal Quantin <pascal.quantin@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Michael Mann <mmann78@netscape.net>
2017-10-26 22:57:30 +00:00
Guy Harris 458c3c026e Add a ws_in6_addr typedef for struct e_in6_addr.
That allows a parallel typedef of ws_in4_addr for guint32.

Change-Id: I03b230247065e0e3840eb87635315a8e523ef562
Reviewed-on: https://code.wireshark.org/review/24073
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-10-26 08:50:34 +00:00
Michael Mann cb89fdd1f6 Add support for BASE_OUI
Modeled after BASE_PT_XXX, this will format a FT_UINT24 to look a OUI, in the form of:
XX:XX:XX (Manufacturer Name) for display.
For display filtering, it will treat the value as hexadecimal.

It requires that FT_UINT24 be the field type.

Change-Id: I8716ae4dfcd4e854764a2425e2ff13c50f571d52
Reviewed-on: https://code.wireshark.org/review/23869
Reviewed-by: Richard Sharpe
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2017-10-15 22:44:47 +00:00
Michael Mann 337f49243f Add ptvcursor APIs that return the values it retrieves
ptvcursor_add_ret_uint
ptvcursor_add_ret_int
ptvcursor_add_ret_string
ptvcursor_add_ret_boolean

Change-Id: I41fa91b1ab805778d34a61215830b12a1331e864
Reviewed-on: https://code.wireshark.org/review/23895
Reviewed-by: Michael Mann <mmann78@netscape.net>
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2017-10-13 06:45:37 +00:00
Michael Mann d8d60b4980 Add ENC_VARINT_PROTOBUF
Encoding of integer datatypes of Protocol buffers
https://developers.google.cn/protocol-buffers/docs/encoding

Change-Id: I9f6d65ddca099c15c0634984e9394131f98d35a9
Reviewed-on: https://code.wireshark.org/review/23813
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2017-10-09 11:31:19 +00:00
João Valverde 221a2bcbd0 Move some DIAG_OFFs to make code less ugly
Change-Id: I0f343ab69a6592a466e12e5d258f0878b9c32c25
Reviewed-on: https://code.wireshark.org/review/23752
Petri-Dish: João Valverde <j@v6e.pt>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: João Valverde <j@v6e.pt>
2017-09-26 17:28:10 +00:00
Guy Harris 7517b73e74 Replace DISSECTOR_ASSERT(hfinfo->type == FT_STRING) with DISSECTOR_ASSERT_FIELD_TYPE.
That produces better error messages, giving the name of the offending
field.

Change-Id: I155ac29c68ecd7811cc9752980db9cdc37fea72e
Reviewed-on: https://code.wireshark.org/review/23685
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-09-24 20:02:20 +00:00
Michael Mann 2b0e08378f Allow distinction between bitmasked 32bit and 64bit unsigned integers in proto_tree_set_representation_value.
IS_FT_UINT includes both 32 and 64 bit unsigned integers, but fvalue_get_uinteger
only allows 32-bit values, so add IS_FT_UINT32 macro for distinguishing between
using fvalue_get_uinteger and fvalue_get_uinteger64.

All other cases that use fvalue_get_uinteger vs fvalue_get_uinteger64 are done
first with switch statements and don't rely on IS_FT_UINT to distinguish
between 32 and 64 bit values

Bug: 14063
Change-Id: I9d1400259e7c2661c2b5ebf96aaa0e9d773651fe
Reviewed-on: https://code.wireshark.org/review/23528
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2017-09-14 02:13:05 +00:00
Pascal Quantin ce7b994383 proto.c: fix use of proto_tree_add_text(_valist)_internal() with length = -1
When using a length of -1, use the tvb remaining length instead of 0.

Change-Id: I569e9c9f57531914a3b613c3a6a9bff076fba362
Reviewed-on: https://code.wireshark.org/review/22931
Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
Petri-Dish: Pascal Quantin <pascal.quantin@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2017-08-04 05:55:34 +00:00
Christoph Wurm 36ac2e9588 Fix missing geninfo in PDML export.
Change-Id: I02b6ff7f57f81f0ac6b54806a9325ebb16b40476
Reviewed-on: https://code.wireshark.org/review/22553
Reviewed-by: Michael Mann <mmann78@netscape.net>
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2017-07-10 08:59:26 +00:00
Guy Harris 1a7f9b957f Revert "Temporary debugging hack, the sequel - fewer printouts, flush before crash."
This reverts commit fa3aa67817.

Change-Id: I974606b2c7963d92832b74e05681431442542202
Reviewed-on: https://code.wireshark.org/review/22200
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-06-18 02:01:17 +00:00
Guy Harris fa3aa67817 Temporary debugging hack, the sequel - fewer printouts, flush before crash.
Change-Id: I867c1f78554fc6fabd2579107fe679a6f6033c0c
Reviewed-on: https://code.wireshark.org/review/22199
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-06-18 01:01:46 +00:00
Guy Harris e77817cc92 Revert "Temporary hack to try to debug tshark -G values crash on 32-bit Windows."
This reverts commit 573a4c9cd5.

Change-Id: Ia967e1e7ae617556cb2d0247fa45026f610bafa8
Reviewed-on: https://code.wireshark.org/review/22198
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-06-17 23:42:19 +00:00
Guy Harris 573a4c9cd5 Temporary hack to try to debug tshark -G values crash on 32-bit Windows.
Change-Id: I837a1e724f58f3e85ae4d7c77715e185a4b1ebeb
Reviewed-on: https://code.wireshark.org/review/22197
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-06-17 21:55:01 +00:00
Guy Harris 4370054431 Clean up whitespace.
Change-Id: I67616d3ea6d325000c22c550c4d20c320b1c51db
Reviewed-on: https://code.wireshark.org/review/22195
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-06-17 21:51:07 +00:00
Jim Young 24d991dab4 Fixup support of BASE_UNIT_STRING for 64 bit based integer fields
proto.c’s proto_custom_set() was missing a test for
BASE_UNIT_STRING under the 64 bit based integer case.  Any
custom columns sourced from a field stored in a 64 bit integer
and having the BASE_UNIT_STRING attribute would only display the
units but not the actual number.

With this patch 64 bit based integer fields having the
BASE_UNIT_STRING attribute will now properly display both
their value and units when added to the packet list as a
custom column.

Change-Id: Icb9532771eb2f4098891dedd82886fd6223ce7a6
Reviewed-on: https://code.wireshark.org/review/21771
Petri-Dish: Jim Young <jim.young.ws@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
Petri-Dish: Alexis La Goutte <alexis.lagoutte@gmail.com>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2017-05-28 15:15:18 +00:00
Michael Mann 827cb68298 proto_tree_add_bytes_format[_value] can handle NULL trees
v2.3.0rc0-3618-gd962e7ae71 tried to simplify logic, but missed
use of TRY_TO_FAKE_THIS_REPR.  Create a "friendlier" version
TRY_TO_FAKE_THIS_REPR_NESTED which allows for the "base"
proto_tree_add_xxx to be called in proto_tree_add_xxx_format[_value]
functions.

Bug: 13736
Change-Id: I98883ad4581d2327edb8da5efd8ef8a89b55e3d0
Reviewed-on: https://code.wireshark.org/review/21764
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2017-05-28 15:12:28 +00:00
Alexis La Goutte cf93801276 proto.c : fix indent
Change-Id: Ib2f9b7bee59d6fa60972df7adf7caaaf9921d975
Reviewed-on: https://code.wireshark.org/review/21776
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
2017-05-28 14:10:43 +00:00
Michael Mann d962e7ae71 Simplify proto_tree_add_bytes_format[_value]
Call proto_tree_add_bytes first so it can do all of the basic
field checks that were being duplicated.

Change-Id: Idc9a3cbf9498aa612a39cc80e3381eba52ce9fa4
Reviewed-on: https://code.wireshark.org/review/21750
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2017-05-25 06:14:45 +00:00
Michael Mann 21735ead4f Add unit_name_string_get_double to handle float/double fields
Bug: 13705
Change-Id: I6bd006f216440d071e5c1eeb6b1f996b4a364c62
Reviewed-on: https://code.wireshark.org/review/21629
Reviewed-by: Michael Mann <mmann78@netscape.net>
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-05-14 01:57:37 +00:00
Martin Kaiser 4e28cf02c5 Fix header field info checks for FT_UINT_BYTES.
It should be allowed to have an FT_UINT_BYTES hf entry with
BASE_NONE|BASE_ALLOW_ZERO. At the moment, this triggers an assert:

Err  Field 'Data block' (image-gif.data_block) is an FT_UINT_BYTES
but is being displayed as (Bit count: 2048) instead of BASE_NONE

For FT_UINT_BYTES entries, we should make the same checks as for
FT_BYTES. Don't fall through to the default case.

Change-Id: I986a9b779d130919d17595f08b3b63306b3956f2
Reviewed-on: https://code.wireshark.org/review/21606
Reviewed-by: Martin Kaiser <wireshark@kaiser.cx>
Petri-Dish: Martin Kaiser <wireshark@kaiser.cx>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2017-05-12 03:16:21 +00:00
Graham Bloice 8c576051fd More fields, more pre-allocated memory for fields.
Change-Id: I36469fad59d28a1fbf15d3fd99544a3a6b0ef015
Reviewed-on: https://code.wireshark.org/review/21569
Petri-Dish: Graham Bloice <graham.bloice@trihedral.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Graham Bloice <graham.bloice@trihedral.com>
2017-05-09 14:55:27 +00:00
Guy Harris 015d9194e1 Add proto_tree_add_item_ret_boolean().
It does what it says on the label.  You get back TRUE or FALSE in a
gboolean.

While we're at it, remove a copied-and-pasted comment that doesn't
apply, and update another comment.

Change-Id: I117391d2ffe44124a614a7f64dad1b389c1ebc6a
Reviewed-on: https://code.wireshark.org/review/21394
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-04-28 01:24:39 +00:00
Michael Mann 2c921eb83c Add proto_tree_add_item_ret_uint64
Just like proto_tree_add_item_ret_uint, but with 64-bit support

Change-Id: Ie0cbfda9e63bf21e85df2d674e391a6c0abe92f7
Reviewed-on: https://code.wireshark.org/review/21355
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2017-04-26 23:46:32 +00:00
Guy Harris 913f9fb353 Rename BASE_VALS_NO_UNKNOWN to BASE_SPECIAL_VALS.
It makes it a bit clearer what its purpose is - to allow a value_string
to be used for numeric rather than enumerated fields, giving certain
values of the field a special meaning.

Change the explanation in the documentation to match as well.

Change-Id: Id07b22eee996b79ea5f3473928d29adcabe09bf3
Reviewed-on: https://code.wireshark.org/review/21209
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-04-18 22:28:07 +00:00
Guy Harris 4d2d423106 Rename routines to clarify what they do.
XXX_prime_with_YYY makes it a bit clearer than does XXX_prime_YYY that
we're not priming YYY, we're priming XXX *using* YYY.

Change-Id: I1686b8b5469bc0f0bd6db8551fb6301776a1b133
Reviewed-on: https://code.wireshark.org/review/21031
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-04-12 04:56:49 +00:00
Alexis La Goutte 043df01c56 Add support for BASE_VALS_NO_UNKNOWN
BASE_VALS_NO_UNKNOWN is a special value_string value for only a single
(maybe 2) numerical value(s).  If a field has the numerical value
that doesn't match anything in the value_string, just the number
is supplied for the field (no "Unknown")

Dissectors that had this use case have been converted in the patch.

Change-Id: Ie63a36cceec2fe4436938ec7e3d7f9e690d2b8d9
Reviewed-on: https://code.wireshark.org/review/20736
Petri-Dish: Michael Mann <mmann78@netscape.net>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2017-04-10 20:31:37 +00:00
Guy Harris 2c44a7f930 Clean up handling of enabled/disabled protocols/heuristic dissectors.
Add a "report a warning message" routine to the "report_err" code in
libwsutil, and rename files and routines appropriately, as they don't
only handle errors any more.

Have a routine read_enabled_and_disabled_protos() that reads all the
files that enable or disable protocols or heuristic dissectors, enables
and disables them based on the contents of those files, and reports
errors itself (as warnings) using the new "report a warning message"
routine.  Fix that error reporting to report separately on the disabled
protocols, enabled protocols, and heuristic dissectors files.

Have a routine to set up the enabled and disabled protocols and
heuristic dissectors from the command-line arguments, so it's done the
same way in all programs.

If we try to enable or disable an unknown heuristic dissector via a
command-line argument, report an error.

Update a bunch of comments.

Update the name of disabled_protos_cleanup(), as it cleans up
information for disabled *and* enabled protocols and for heuristic
dissectors.

Support the command-line flags to enable and disable protocols and
heuristic dissectors in tfshark.

Change-Id: I9b8bd29947cccdf6dc34a0540b5509ef941391df
Reviewed-on: https://code.wireshark.org/review/20966
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-04-08 20:40:08 +00:00
Michael Mann 2eca457d52 Display numeric fields in their base display type for columns.
Don't force display of BASE_DEC

Change-Id: Id6f115c074f0d4b1bd277dcbf6c523ffaa295edb
Reviewed-on: https://code.wireshark.org/review/20918
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2017-04-05 10:54:17 +00:00
Guy Harris 19bb1b128b Provide better error messages for field type mismatches.
Don't just report an assertion failure with a line in proto.c; give the
name of the field with the wrong type, and a list of the types that are
valid for the routine in question.

Change-Id: Id3ed7c376fdc72bf6cff69c647833946cfa99ee6
Reviewed-on: https://code.wireshark.org/review/20824
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-04-01 02:42:22 +00:00
AndersBroman 572b80d283 Add ENC_TIME_MSEC_NTP and use it in packet-gtpv2.c
While at it fix expert info a typo and an calculation.

Change-Id: I071a36edb7eed5f58708b98aebcb24bc6c34f2a8
Reviewed-on: https://code.wireshark.org/review/20766
Petri-Dish: Anders Broman <a.broman58@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2017-03-29 05:09:54 +00:00
Guy Harris 79ba8c3976 Print signed values with %d, not %u.
Change-Id: I1ad46df006976c052ff42baf6415e18b488b215f
Reviewed-on: https://code.wireshark.org/review/20780
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-03-29 04:16:52 +00:00
Guy Harris 8f515b1a99 Fix up time encodings.
Add some new encodings for absolute time stamps, and use them as
appropriate; this fixes some cases where the time stamps in question
were being dissected incorrectly.

For the encodings with seconds and 1/2^32s of a second, don't
arbitrarily give only microsecond resolution; 2^32 is greater than 1
million, and, in fact, at least some NTP RFCs explicitly talk about time
resolution greater than 1 microsecond.

Update references in the RELOAD dissector to reflect the documents in
question having been updated and published as RFCs.

Change-Id: Icbe0b696d65eb622978eb71e99ddf699b84e4fca
Reviewed-on: https://code.wireshark.org/review/20759
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-03-28 10:18:36 +00:00
Guy Harris bb2ab6ac96 Don't speak of RTPS time_t as an "NTP" time.
It's some weird hybrid of UN*X time and NTP time stamps, using UN*X's
epoch and NTP's seconds/fractions split.  I'm sure they had their
reasons for not using something like struct timespec or regular NTP
time, and instead inventing something that's halfway in between them.

Change-Id: I1f39ec1368af52b82adfa2a22677dfa6e9341309
Reviewed-on: https://code.wireshark.org/review/20711
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-03-26 04:59:35 +00:00
Guy Harris a6730565f8 Add ENC_TIME_TIMEVAL and use it for gsmtap.
From a look at the libosmocom code, time stamps in
GSMTAP_TYPE_OSMOCORE_LOG messages appear to be UN*X struct timevals with
a 4-byte tv_sec, not anything NTP-like with the fraction-of-a-second
part in units of 1/2^32s of a second.

Add ENC_TIME_TIMEVAL to handle time stamps like that, and use it rather
than ENC_TIME_NTP_BASE_ZERO.

Change-Id: Ia1511527ee292fb7725b2a64c0af16d23ff10a6d
Reviewed-on: https://code.wireshark.org/review/20710
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2017-03-26 04:38:11 +00:00
Alexis La Goutte f9fe43d282 proto: fix this condition has identical branches [-Werror=duplicated-branches] found by gcc7
Change-Id: Ie8590d6c94b19697cff33874c5bc0b76024d337f
Reviewed-on: https://code.wireshark.org/review/20693
Reviewed-by: Michael Mann <mmann78@netscape.net>
2017-03-24 09:51:20 +00:00
Alexis La Goutte 01b460fb77 proto(.c): remove unused check and fix indent..
Change-Id: I30b44cb0145f76c3929cac92337756a4164df1d2
Reviewed-on: https://code.wireshark.org/review/20609
Reviewed-by: Juan Jose Martin Carrascosa <juanjo@rti.com>
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2017-03-20 01:28:01 +00:00
Stig Bjørlykke 528a3d31ff proto: Check for empty protocol->fields
In proto_get_first_protocol_field() we must check for an empty
protocol->fields because Lua scripts may have protocols without
fields and g_ptr_array_index() does not perform bounds checking
on the given index.

Bug: 13223
Change-Id: Ib2f6286d0799541243450348dcf345a965b2825c
Reviewed-on: https://code.wireshark.org/review/20455
Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2017-03-09 08:58:27 +00:00
AndersBroman 2d0e4c3730 include <wsutil/glib-compat.h> to allow use of g_list_free_full() with
older glibs.

Change-Id: I3eb7e178dcb844ddbac47f53f221a98e2d32f413
Reviewed-on: https://code.wireshark.org/review/20334
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2017-03-02 11:37:50 +00:00
AndersBroman e2e4415c9f Add some glib functions not available in older glibs
Change-Id: I6526d799447a3b6c0b9bb42f8d0f8c3415299ed0
Reviewed-on: https://code.wireshark.org/review/20158
Reviewed-by: Anders Broman <a.broman58@gmail.com>
Petri-Dish: Anders Broman <a.broman58@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
2017-02-20 12:55:49 +00:00
Peter Wu fcc9cf2e45 proto: ensure that length is set for proto_tree_add_item_new_ret_length
A user reported that the TNS dissector would show "Malformed Packet" in
the Info column in Qt. The actual packet details and Expert Info dialog
however had no trace of the issue.

It turns out that proto_tree_add_item_new_ret_length did not correctly
set the length. Test case (based on pcap from SampleCaptures wiki):

    tshark -r TNS_Oracle1.pcap -w 19.pcap -Y frame.number==19
    tshark -r 19.pcap -Y tcp

Change-Id: I82cb1ccbc7c3b33d2bcdb22f89a1754c1a4575e7
Fixes: v2.1.0rc0-1394-gc67c6e8f30 ("Add routines to add an item and return the item's real length.")
Reviewed-on: https://code.wireshark.org/review/20098
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Jörg Mayer <jmayer@loplof.de>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2017-02-18 14:21:27 +00:00
AndersBroman 16c3ecbd4c g_slist_free_full requires glib 2.28
Change-Id: I4f9ce7f65da0349b962f6be317635c5acb2daf73
Reviewed-on: https://code.wireshark.org/review/20148
Petri-Dish: Anders Broman <a.broman58@gmail.com>
Reviewed-by: Dario Lombardo <lomato@gmail.com>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2017-02-16 21:03:44 +00:00