Commit Graph

997 Commits

Author SHA1 Message Date
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