aboutsummaryrefslogtreecommitdiffstats
path: root/epan/proto.c
AgeCommit message (Collapse)AuthorFilesLines
2019-11-12Fix display of pino protocols in display filter dropdownPascal Quantin1-16/+10
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-10-28wslua: Fix memleak of unregistered ProtoField stringsStig Bjørlykke1-82/+90
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-09-05kafka: Cleanup to use "native" APIs.Michael Mann1-12/+79
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-04Load environment vars to globals for efficency.Anders Broman1-2/+2
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-08-29Add proto_tree_add_item_ret_time_stringMichael Mann1-4/+109
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-07-29proto: fix proto_item_add_bitmask_tree with zero lengthPeter Wu1-4/+9
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-26HTTPS (almost) everywhere.Guy Harris1-1/+1
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-25Don't format printable non-ASCII Unicode characters as escape sequences.Guy Harris1-2/+1
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-06-20Remove the UTF-8 validation from proto_tree_add_string().Guy Harris1-4/+0
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-12Don't check lenretval in proto_tree_add_item_ret_display_string_and_length().Guy Harris1-4/+2
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-08Have routines to add a protocol tree item and return a display string.Guy Harris1-116/+203
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-07Improve handling of binary data that *might* be text.Guy Harris1-74/+115
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-05-24"Zigbee" encoding is not a character encoding or an integer encoding.Guy Harris1-10/+2
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-14elastic: make fields all the same.Dario Lombardo1-1/+1
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-13elastic: change 'pcap_file' into 'doc' in the mapping.Dario Lombardo1-3/+3
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-13elastic: change 'template' into 'index_patterns' in the mapping.Dario Lombardo1-1/+1
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-13elastic: use correct elastic field types in mapping.Dario Lombardo1-5/+5
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-03proto: don't generate elastic-mapping entries for string fields.Dario Lombardo1-30/+15
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-04-04epan: Convert our PROTO_ITEM_ macros to inline functions.Gerald Combs1-12/+12
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-01add to get_time_value() case ENC_TIME_MSECS|ENC_LITTLE_ENDIAN:kanidef1-0/+1
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-03-07We need more pre-allocated fields.Guy Harris1-1/+1
Change-Id: I17affbd71b89d5fa9615ca1984ef6c38d21e8baf Reviewed-on: https://code.wireshark.org/review/32345 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2019-02-08Fixing some implicit coversations (-Wshorten-64-to-32)Uli Heilmeier1-2/+2
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-01-27wslua: fix memleaks related to Proto and PrefPeter Wu1-0/+2
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-13proto: ensure valid width through assert.Dario Lombardo1-1/+4
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-03epan: remove redundant casts.Dario Lombardo1-6/+6
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>
2018-12-09proto: make ws_type_to_elastic static.Dario Lombardo1-1/+2
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-11-20Replace JSON-GLib by custom JSON dumper libraryPeter Wu1-79/+61
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-08proto.c: increase the number of pre allocated fieldsPascal Quantin1-1/+1
Change-Id: I5b2cb3ae6a9e6ab507f18e6eb5f89a37b2983129 Reviewed-on: https://code.wireshark.org/review/30551 Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
2018-11-01Fix "Follow TLS Stream" after ssl -> tls renamePascal Quantin1-3/+3
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-01Revert "FT_BYTES: fix dissection of FT_BYTES when using SEP_SPACE and "NONE" ↵Pascal Quantin1-2/+1
options" This reverts commit 0457e6041942776ecff9d4377fc0ce5a340dbb7a. Change-Id: Id39722872efbe98648754d7543da7ae5b08f8b67 Reviewed-on: https://code.wireshark.org/review/30451 Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
2018-11-01FT_BYTES: fix dissection of FT_BYTES when using SEP_SPACE and "NONE" optionsJeremy Martin1-1/+2
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-10-27IAX: Use extended 64 bit value to string matching for codecsTom Hughes1-2/+6
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-27Add support for extended 64 bit value to string matchingTom Hughes1-16/+42
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-19proto.c: Add hint to an assert.AndersBroman1-1/+1
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-17wslua: Add support for base.RANGE_STRING handling.Richard Sharpe1-0/+6
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-09-19Try to discourage the use of APIs via counting.Gerald Combs1-3/+3
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-10proto.c: Increase number of preallocted fields to 205000AndersBroman1-1/+1
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-05proto: Reset handled occurrences counterStig Bjørlykke1-1/+3
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-04epan: Restrict detect trailing stray characters in stringsStig Bjørlykke1-13/+21
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-08-31Add support for protocol aliases. Switch BOOTP to DHCP.Gerald Combs1-0/+51
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-31epan: Detect trailing stray characters in stringsStig Bjørlykke1-2/+59
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-29epan: Remove unnecessary all protocols registration callbackJoão Valverde1-7/+13
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-29Make AT_VINES a built-in typeJoão Valverde1-7/+1
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-20Increase PROTO_PRE_ALLOC_HF_FIELDS_MEMJoão Valverde1-1/+1
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-09proto.c: allow more field types for proto_tree_add_item_ret_uint64()Pascal Quantin1-2/+8
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-07-16Supply a 0s/0ns value for invalid time value lengths.Guy Harris1-17/+68
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-02Add new encoding names for seconds/{micro,nano}second time stamps.Guy Harris1-8/+8
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-02Add support for 8+8 and 8+4 struct timespec, and use it with 9P.Guy Harris1-45/+68
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-06-10Do bounds checking of the offset and length in proto_tree_add_string().Guy Harris1-0/+16
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-03Free dynamic header fields on exitStig Bjørlykke1-0/+1
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>