Commit Graph

451 Commits

Author SHA1 Message Date
Guy Harris 1f595c435c BER: get rid of WTAP_FILE_TYPE_SUBTYPE_BER.
Save a copy of the pathname used to open a file in the wtap structure.
This allows the BER file reader to put a pointer to it in the
pseudo-header; it also would allow file readers to attempt to read
"associated" files that have the same name as the file, but with a
different extension.

Instead of having cf_open() special-case BER files, and calling a
routine in the BER dissector to specify the file name to the dissector,
have separate dissectors for "dissect packet payload as BER" and
"dissect a file as BER", and have the latter get the pathname of the
file from the pseudo-header and determine the ASN.1 syntax from that.

(Side-effect - this means that you can now dissect a BER file, and have
the syntax be determined by the file extension, in TShark as well; the
above cf_open() special-casing was *not* done in TShark, so it didn't
work before.  Now the application code doesn't need to do any of that,
so it works in TShark as well as Wireshark.)
2021-02-20 01:36:26 -08:00
Anders Broman 699f1f9041 BER: Fix debug statement 2020-11-23 08:42:50 +01:00
Martin Mathieson 6894bccf03 check_tfs.py: Also match case insensitively
Fix up some issues where the words were the same except for
captitalisation.
2020-10-11 18:46:31 +00:00
Martin Mathieson e48ab21267 BER: Fix order of loop tests to avoid overrunning array.
Reported by cppcheck:

epan/dissectors/packet-ber.c:2603:35: warning: Array index 'set_idx' is used before limits check. [arrayIndexThenCheck]
    for (set_idx = 0; (cset = &set[set_idx])->func && (set_idx < MAX_SET_ELEMENTS); set_idx++) {
                                  ^
epan/dissectors/packet-ber.c:2759:40: warning: Array index 'set_idx' is used before limits check. [arrayIndexThenCheck]
        for (set_idx = 0;  (cset = &set[set_idx])->func && (set_idx < MAX_SET_ELEMENTS); set_idx++) {
                                       ^

Change-Id: Ifbb9f1d2e9062a5c55190ea68df2226f3af8f21a
Reviewed-on: https://code.wireshark.org/review/38166
Petri-Dish: Martin Mathieson <martin.r.mathieson@googlemail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Pascal Quantin <pascal@wireshark.org>
Reviewed-by: Martin Mathieson <martin.r.mathieson@googlemail.com>
2020-08-16 21:49:04 +00:00
Martin Mathieson 9a7b30aea8 Fix tfs strings that have leading or trailing space characters.
Change-Id: I3e456e24f171ea2073806ad56606e6ce9092890c
Reviewed-on: https://code.wireshark.org/review/38096
Petri-Dish: Martin Mathieson <martin.r.mathieson@googlemail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Pascal Quantin <pascal@wireshark.org>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2020-08-09 13:31:33 +00:00
Anders Broman 133dbc2178 BER: Add the posibillity to do "decode as" on an UDP port.
Change-Id: I2897b32b58f154c9998316b16d24bf97ef544153
Reviewed-on: https://code.wireshark.org/review/37628
Petri-Dish: Anders Broman <a.broman58@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2020-07-01 07:24:04 +00:00
Guy Harris e1d9a226a2 Fix the type of arrays of pointers to hf_ values for bitfield routines.
The static arrays are supposed to be arrays of const pointers to int,
not arrays of non-const pointers to const int.

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

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

Update documentation and dissector-generator tools.

Change-Id: I789da5fc60aadc15797cefecfd9a9fbe9a130ccc
Reviewed-on: https://code.wireshark.org/review/37517
Petri-Dish: Guy Harris <gharris@sonic.net>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2020-06-19 11:32:26 +00:00
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 Mathieson 7e02165453 More issues spotted by PVS-Studio in bug 16335.
Only the change to packet-imap.c really represents a bug.

Change-Id: Ie270f97f3d94c338ea3c84a712f8f4d43ffd36f4
Reviewed-on: https://code.wireshark.org/review/36115
Petri-Dish: Martin Mathieson <martin.r.mathieson@googlemail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2020-02-16 11:51:55 +00:00
Peter Wu d44c5e45cb x509af,ocsp,ber: display serialNumber (INTEGER) as bytes
Certificates used in TLS typically have a serial number larger than 64
bits which do not fit in FT_UINT64 and results in use of the synthetic
ber.64bit_uint_as_bytes field name. To enable use of ocsp.serialNumber
and x509af.serialNumber field names, define these as bytes instead.

Update the BER dissector to allow INTEGER types to use FT_BYTES.

Bug: 16339
Change-Id: Id58075b450d86aff6b616c359900ae83a3ec2f51
Reviewed-on: https://code.wireshark.org/review/35868
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot
Reviewed-by: Pascal Quantin <pascal@wireshark.org>
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
2020-01-21 22:10:45 +00:00
Andre Luyer dbfb204f48 ber: display x509af.utcTime year in 4 digits
Because:
- the 2-digit year can only be in the range 1950..2049 according to
https://tools.ietf.org/html/rfc5280#section-4.1.2.5.1
- to avoid confusion, interpreting the year/month/day in a different order may
still represent a valid date.
- now both utcTime and GeneralizedTime are displayed in exactly the same way.
- some tools, like Perl, apply a different date range when converting 2-digit years.

In packet-ber.c two parameters are added to the function dissect_ber_UTCTime:
datestrptr: if not NULL return datetime string instead of adding to tree
or NULL when packet is malformed
tvblen: if not NULL return consumed packet bytes
Also the memory allocation for outstr is now done using the recommended method
as described in the README.developer document.

The calling function in x509af/x509sat uses this to prepend the century.
Added generated files.

Change-Id: I714c2e8e7f899211caaa1f4136ca0d27cb1aba4a
Reviewed-on: https://code.wireshark.org/review/35414
Petri-Dish: Pascal Quantin <pascal@wireshark.org>
Tested-by: Petri Dish Buildbot
Reviewed-by: Stig Bjørlykke <stig@bjorlykke.org>
Reviewed-by: Pascal Quantin <pascal@wireshark.org>
2020-01-11 18:36:35 +00:00
Pascal Quantin 11aef7c19b BER: fix ber.error.bits_unknown display
Before the changes done in v3.1.0rc0-431-gc2ac157ac0 and
v3.1.0rc0-458-g37b91eedd6 the expert info was only displayed
if at least 1 unknown bit was set to 1. Restore this behavior.

Bug: 16301
Change-Id: I3bea0992d6727154ef07d40ac18a7b012d3c1da4
Reviewed-on: https://code.wireshark.org/review/35612
Petri-Dish: Pascal Quantin <pascal@wireshark.org>
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot
Reviewed-by: Pascal Quantin <pascal@wireshark.org>
2020-01-02 21:56:44 +00:00
Guy Harris 20800366dd HTTPS (almost) everywhere.
Change all wireshark.org URLs to use https.

Fix some broken links while we're at it.

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

Change-Id: Ibd9d4acbe9cad2c1af520340d04e550326a97ebe
Reviewed-on: https://code.wireshark.org/review/33557
Petri-Dish: Martin Kaiser <wireshark@kaiser.cx>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2019-06-11 18:50:32 +00:00
Guy Harris f72e504817 Dissect LDAP strings as UTF-8.
This requires some special hackery, including a new packet-ber.c
routine, as those strings are just OCTET STRINGs, not UTF8Strings.

Change-Id: I776ed47f7400eba366a630b60b94be3397f7b45f
Reviewed-on: https://code.wireshark.org/review/33403
Petri-Dish: Guy Harris <guy@alum.mit.edu>
Tested-by: Petri Dish Buildbot
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2019-05-28 04:11:35 +00:00
Pascal Quantin c1dcf8c3fa BER: put the space to the left side of the bracket
Change-Id: I43dd6736e915b25687fcebe79219a365bf01db08
Reviewed-on: https://code.wireshark.org/review/32835
Reviewed-by: Pascal Quantin <pascal@wireshark.org>
2019-04-12 08:41:45 +00:00
Peter Wu a96d0bb946 BER: fix regression in dissection of named bit list
The bitmask for every header field is 8 bits, do not pass 64-bit values
to proto_tree_add_bitmask_list since the bitmask would always match
against the (possibly wrong) lower 8 bits. Instead process 8 bits at a
time, as before gc2ac157ac0.

Since g37b91eedd6, a dissector exception is thrown when the number of
bytes covering the BIT STRING value is smaller than the number of named
bit fields. (Trailing zero bits in a BIT STRING with named bit fields do
not have to be encoded.) Fix this by assuming zeroes.

Restructure the code to reduce duplication and add some comments. Tested
with the capture from 15684 (attachment 17045), check the keyUsage
extension in the Certificate message (frame 5).

Bug: 15673
Change-Id: Ifa010b9df3e4b46941c00e4f830a03efc589ac21
Fixes: v3.1.0rc0-431-gc2ac157ac0 ("ASN.1: Use  proto_tree_add_bitmask... () for named bits.")
Fixes: v3.1.0rc0-458-g37b91eedd6 ("BER: fix dissection of bitmask lists with an invalid length")
Reviewed-on: https://code.wireshark.org/review/32820
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2019-04-12 08:38:01 +00:00
Pascal Quantin 37b91eedd6 BER: fix dissection of bitmask lists with an invalid length
Bug: 15673
Change-Id: Ia737d7b446114e5da9684201344436d80266f0a2
Reviewed-on: https://code.wireshark.org/review/32721
Petri-Dish: Pascal Quantin <pascal@wireshark.org>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2019-04-05 04:07:00 +00:00
Anders Broman c2ac157ac0 ASN.1: Use proto_tree_add_bitmask... () for named bits.
Change-Id: Ied0c91ea070ee76603e7ecb29d874e0c1a65892e
Reviewed-on: https://code.wireshark.org/review/32684
Petri-Dish: Anders Broman <a.broman58@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2019-04-03 14:53:08 +00:00
Guy Harris cced5fb949 Constification, to remove some compiler warnings.
Change-Id: I24f0bdc72109a6ef3d801dc28cb9b523ff4e5fe7
Reviewed-on: https://code.wireshark.org/review/32458
Petri-Dish: Guy Harris <guy@alum.mit.edu>
Tested-by: Petri Dish Buildbot
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2019-03-17 21:09:34 +00:00
Dario Lombardo 3cd5ac36e2 BER: don't use invalid time offsets.
4 digits values could overflow the destination buffer. Skip them
since they're invalid and can only from tainted data.

Bug: 15447
Change-Id: Ice6d4f144597499483160ecaa63702025ab86f61
Reviewed-on: https://code.wireshark.org/review/31751
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
2019-01-28 15:00:33 +00:00
Alexis La Goutte 9b03b6fc8e ber: Fix Dead Store (Dead assignement/Dead increment) Warning found by Clang
Change-Id: I9cab3c6e6308b8603dede34ccf907dd326c23957
Reviewed-on: https://code.wireshark.org/review/28211
Petri-Dish: Dario Lombardo <lomato@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Dario Lombardo <lomato@gmail.com>
2018-06-12 14:21:11 +00:00
Guy Harris e020ccab49 Fix again.
Change-Id: I054df4458c7ef9f6e108c9d9a5f29e2546c28041
Reviewed-on: https://code.wireshark.org/review/28101
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2018-06-08 05:05:06 +00:00
Guy Harris 36c79feda8 Fix indentation.
Change-Id: Ib89cc2b7f416422868fb6f7c2f8f7bc1f9b347bf
Reviewed-on: https://code.wireshark.org/review/28097
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2018-06-08 05:02:58 +00:00
Guy Harris 0a9e92d585 Use proto_tree_add_expert{_format}() to report errors.
Don't create fake string items.

Have the item cover the part of the packet that has the issue, e.g. if
there's an unexpected identifier, or an invalid length, cover that
rather than the value; that 1) shows where the problem is and 2) avoids
throwing an exception.

Clean up the error messages and expert info items while we're at it.

Change-Id: If698db98158f7a5532a865be02f1028d92af262f
Reviewed-on: https://code.wireshark.org/review/28093
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2018-06-08 05:00:35 +00:00
Guy Harris 2f9c61f03f Name update.
With the name change from Ethereal to Wireshark, asn2eth was renamed
asn2wrs.

Change-Id: I5bdfa2362ca7de81b0bda6ec9faa78cdb0ba10b4
Reviewed-on: https://code.wireshark.org/review/27968
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2018-06-02 22:11:52 +00:00
Peter Wu 67c6420473 ber: clamp BER lengths to avoid integer overflow
Many callers treat the length as signed integer, so ensure that the
length fits in such a number. Failure to do so can have unintended
consequences (such as calling "tvb_memdup(tvb, 0, -1)" and assuming that
the length is actually 2^32-1).

Although an exception could be thrown as well, let's give the caller a
chance to handle this themselves.

Change-Id: If92545f7d3603250f75741040435000ba879b7e3
Ping-Bug: 14682
Reviewed-on: https://code.wireshark.org/review/27563
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-05-15 17:17:33 +00:00
Peter Wu df5a8b29bb ber: fix buffer overrun (read) in dissect_ber_constrained_bitstring
The length is an unsigned integer, but some users (such as tvb_memdup)
expect signed integers and treat negative values specially.

Bug: 14682
Change-Id: Ic3330d23d964b5cc44718b61c8985880f901674d
Link: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=8011
Reviewed-on: https://code.wireshark.org/review/27562
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-05-15 17:17:07 +00:00
Роман Донченко 3ba56ce586 wiretap: Add a reader for files in the PEM-like format specified by RFC 7468
Change-Id: I8109025120d01c915f3a9d5550aa9272ec83893a
Reviewed-on: https://code.wireshark.org/review/27334
Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org>
Reviewed-by: Stig Bjørlykke <stig@bjorlykke.org>
2018-05-15 12:47:06 +00:00
Alexandr Savca b545c60658 Fix cppcheck 1.83 warnings
[packet-ber.c:2687]: (error) Shifting signed 32-bit value by 31 bits is undefined behaviour
[packet-erf.c:2475]: (error) Shifting signed 32-bit value by 31 bits is undefined behaviour
[packet-fmp.c:378]: (error) Shifting signed 32-bit value by 31 bits is undefined behaviour
[packet-http2.c:2050]: (error) Shifting signed 32-bit value by 31 bits is undefined behaviour
[packet-obd-ii.c:643]: (error) Shifting signed 32-bit value by 31 bits is undefined behaviour
[packet-yami.c:244]: (error) Shifting signed 32-bit value by 31 bits is undefined behaviour

Change-Id: Ie71f9f7c8f863d1e9c693bd56444f00bdad48042
Reviewed-on: https://code.wireshark.org/review/27019
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Reviewed-by: Guy Harris <guy@alum.mit.edu>
Tested-by: Petri Dish Buildbot
2018-04-19 17:31:49 +00:00
Dario Lombardo 6e75a0b277 ber/per: assert actx to avoid null dereference (found by clang).
Change-Id: I4efc6d30060bf8842d5facdd3151385b805fe22b
Reviewed-on: https://code.wireshark.org/review/26136
Petri-Dish: Dario Lombardo <lomato@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
2018-03-12 07:17:01 +00:00
Gerald Combs 2b74b5c4c8 BER: Add a length check.
Add a common large length reporting function. Add a length check to
dissect_ber_set.

Bug: 14444.
Change-Id: I6093b5342439cd0ee08f060b8d74b3ae54b3b8f8
Reviewed-on: https://code.wireshark.org/review/25931
Reviewed-by: Gerald Combs <gerald@wireshark.org>
Petri-Dish: Gerald Combs <gerald@wireshark.org>
Tested-by: Petri Dish Buildbot
Reviewed-by: Michael Mann <mmann78@netscape.net>
2018-02-21 01:06:51 +00:00
Dario Lombardo fe219637a6 dissectors: use SPDX identifiers.
Change-Id: I92c94448e6641716d03158a5f332c8b53709423a
Reviewed-on: https://code.wireshark.org/review/25756
Petri-Dish: Dario Lombardo <lomato@gmail.com>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-02-12 16:49:58 +00:00
Ahmad Fatoum 9d49e13166 Remove superfluous null-checks before strdup/free
NULL checks were removed for following free functions:

- g_free "If mem is NULL it simply returns"
  https://developer.gnome.org/glib/stable/glib-Memory-Allocation.html#g-free

- g_slist_free(_full)? "NULL is considered to be the empty list"
  https://developer.gnome.org/glib/stable/glib-Singly-Linked-Lists.html

- g_strfreev "If str_array is NULL, this function simply returns."
  https://developer.gnome.org/glib/stable/glib-String-Utility-Functions.html#g-strfreev

- g_slice_free "If mem is NULL, this macro does nothing."
  https://developer.gnome.org/glib/stable/glib-Memory-Slices.html#g-slice-free

- g_match_info_free "not NULL... otherwise does nothing"
  https://developer.gnome.org/glib/stable/glib-Perl-compatible-regular-expressions.html#g-match-info-free

- dfilter_free defined in Wireshark code. Returns early when passed NULL
  epan/dfilter/dfilter.c

They were also removed around calls to g_strdup where applicable:

- g_strdup "If str is NULL it returns NULL."
  https://developer.gnome.org/glib/stable/glib-String-Utility-Functions.html#g-strdup

Change-Id: Ie80c2db89bef531edc3aed7b7c9f654e1d654d04
Reviewed-on: https://code.wireshark.org/review/23406
Petri-Dish: Roland Knall <rknall@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: João Valverde <j@v6e.pt>
2017-10-15 12:38:51 +00:00
Jeff Morriss b988d8b392 Fix up dissector tables' UI names.
This was inspired by using the Decode-As UI to decode Field "SSL TCP Dissector"
Value (port) XXX as YYY.  "SSL Port" makes more sense as the UI name.

Change-Id: Id6398a5dc79e32bddc4f1bfcf0a468ae1364808f
Reviewed-on: https://code.wireshark.org/review/19573
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-29 16:12:35 +00:00
Michael Mann af54b292e6 Register reassembly tables
Register all reassembly tables with a central unit, allowing the
central unit to have the callback that initializes and destroys
the reassembly tables, rather than have dissectors do it individually.

Change-Id: Ic92619c06fb5ba6f1c3012f613cae14982e101d4
Reviewed-on: https://code.wireshark.org/review/19834
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-01-29 13:29:04 +00:00
Dario Lombardo 712d2aef72 ber: add shutdown routine.
Change-Id: Idc494f6be0f2fd2187f21bccb870d24655ce1da5
Reviewed-on: https://code.wireshark.org/review/19647
Reviewed-by: Michael Mann <mmann78@netscape.net>
2017-01-20 18:31:29 +00:00
Dario Lombardo 805ddd1add uat: add a reset callback.
This function will free the resources allocated by the caller.

Change-Id: Ib486c14e4fd3c321662fb71f7fd06733ce9a64a4
Reviewed-on: https://code.wireshark.org/review/19375
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2017-01-12 12:39:15 +00:00
Pascal Quantin 321b756dc4 Add T.61 character set support
Bug: 13032
Change-Id: I6bf2cc2c43a6262d899a304df6576d9831115966
Reviewed-on: https://code.wireshark.org/review/18350
Petri-Dish: Michael Mann <mmann78@netscape.net>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Michael Mann <mmann78@netscape.net>
2016-10-22 03:16:11 +00:00
Michael Mann 268841f3e0 Combine Decode As and port preferences for tcp.port dissector table.
This patch introduces new APIs to allow dissectors to have a preference for
a (TCP) port, but the underlying data is actually part of Decode As functionality.
For now the APIs are intentionally separate from the regular APIs that register a
dissector within a dissector table.  It may be possible to eventually combine the
two so that all dissectors that register with a dissector table have an opportunity
to "automatically" have a preference to adjust the "table value" through the
preferences dialog.

The tcp.port dissector table was used as the guinea pig.  This will eventually be
expanded to other dissector tables as well (most notably UDP ports).  Some
dissectors that "shared" a TCP/UDP port preference were also converted. It also
removed the need for some preference callback functions (mostly when the callback
function was the proto_reg_handoff function) so there is cleanup around that.

Dissectors that has a port preference whose default was 0 were switched to using
the dissector_add_for_decode_as_with_preference API rather than dissector_add_uint_with_preference

Also added comments for TCP ports used that aren't IANA registered.

Change-Id: I99604f95d426ad345f4b494598d94178b886eb67
Reviewed-on: https://code.wireshark.org/review/17724
Reviewed-by: Michael Mann <mmann78@netscape.net>
2016-10-08 02:44:53 +00:00
Guy Harris a4c8ebc18b Don't do any Decode As stuff for dissector tables not used with Decode As.
Have all dissector tables have a "supports Decode As" flag, which
defaults to FALSE, and which is set to TRUE if a register_decode_as()
refers to it.

When adding a dissector to a dissector table with a given key, only add
it for Decode As if the dissector table supports it.

For non-FT_STRING dissector tables, always check for multiple entries
for the same protocol with different dissectors, and report an error if
we found them.

This means there's no need for the creator of a dissector table to
specify whether duplicates of that sort should be allowed - we always do
the check when registering something for "Decode As" (in a non-FT_STRING
dissector table), and just don't bother registering anything for "Decode
As" if the dissector table doesn't support "Decode As", so there's no
check done for those dissector tables.

Change-Id: I4a1fdea3bddc2af27a65cfbca23edc99b26c0eed
Reviewed-on: https://code.wireshark.org/review/17402
Petri-Dish: Guy Harris <guy@alum.mit.edu>
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-08-31 00:08:01 +00:00
Michael Mann 1da1f945e2 Fix checkAPI.pl warnings about printf
Many of the complaints from checkAPI.pl for use of printf are when its embedded
in an #ifdef and checkAPI isn't smart enough to figure that out.
The other (non-ifdef) use is dumping internal structures (which is a type of
debug functionality)
Add a "ws_debug_printf" macro for printf to pacify the warnings.

Change-Id: I63610e1adbbaf2feffb4ec9d4f817247d833f7fd
Reviewed-on: https://code.wireshark.org/review/16623
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>
2016-07-25 04:26:50 +00:00
Joerg Mayer 0c471e782f Fix more -Wused-but-marked-unused warnings/errors.
Change-Id: Ieb3e70a23c1a55b7ba60b1b32f159341adfe65b7
Reviewed-on: https://code.wireshark.org/review/14682
Reviewed-by: Jörg Mayer <jmayer@loplof.de>
2016-03-28 19:06:13 +00:00
Michael Mann e37275bfde Associate dissector tables and heuristic subdissector lists with a protocol.
This will make it easier to determine protocol dependencies.

Some LLC OUI dissector tables didn't have an associated protocol, so they were left without one (-1 used)

Change-Id: I6339f16476510ef3f393d6fb5d8946419bfb4b7d
Reviewed-on: https://code.wireshark.org/review/14446
Reviewed-by: Michael Mann <mmann78@netscape.net>
2016-03-17 00:05:17 +00:00
Peter Wu 9ff932bf5e ber: avoid deep recursion for constructed strings
Bound the recursion depth to avoid a stack overflow while parsing a
deeply nested constructed string.

Call chain before this patch:

 - dissect_ber_octet_string
   - dissect_ber_constrained_octet_string
     - reassemble_octet_string (called for constructed types)
       - dissect_ber_octet_string *recursion*

After this patch, the reassemble_octet_string will throw if the maximum
recursion depth is reached.

Bug: 11822
Change-Id: I6753e3c9f5dcbfab0e4c174418b2c7eb784d64d2
Reviewed-on: https://code.wireshark.org/review/14108
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>
2016-02-24 06:06:31 +00:00
Peter Wu 55b5b7caf3 ber: fix buffer overrun when handling empty sets
When a set is empty, only a terminator (ber_sequence_t with NULL func)
is present. In that case, do not try to find more values as that will
never succeed.

Bug: 12106
Change-Id: I26cd4ba84a9580e92d5921592a27c2af17c0bebf
Reviewed-on: https://code.wireshark.org/review/14028
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
2016-02-20 15:06:45 +00:00
João Valverde 5fec8fa746 BER/PER: Add dissector assertions to squelch scan-build bugs
packet-per.c:959:6: warning: Access to field 'aligned' results in a dereference of a null pointer (loaded from variable 'actx')
packet-ber.c:1606:29: warning: Access to field 'pinfo' results in a dereference of a null pointer (loaded from variable 'actx')
packet-ber.c:1612:24: warning: Access to field 'created_item' results in a dereference of a null pointer (loaded from variable 'actx')
packet-ber.c:3156:41: warning: Access to field 'pinfo' results in a dereference of a null pointer (loaded from variable 'actx')
packet-ber.c:3182:24: warning: Access to field 'created_item' results in a dereference of a null pointer (loaded from variable 'actx')

Change-Id: Ibae00dc29a869701fe903a5b0c9944279aaa3df7
Reviewed-on: https://code.wireshark.org/review/13936
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>
2016-02-19 15:48:16 +00:00
João Valverde 95dee44a77 const gpointer -> gconstpointer
'const gpointer' is the same as 'void *const'. Replace with gconstpointer
where straightforward (assuming that was the intent) and use gpointer everywhere
else for clarity (that does not change *API* constness contract; it just means
a variable is not declared immutable inside the called funtion).

Change-Id: Iad2ef13205bfb4ff0056b2bce056353b58942267
Reviewed-on: https://code.wireshark.org/review/13945
Petri-Dish: Anders Broman <a.broman58@gmail.com>
Petri-Dish: Alexis La Goutte <alexis.lagoutte@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2016-02-16 05:10:49 +00:00
Guy Harris bc5a0374bf Add the packet number to the packet_info structure, and use it.
That removes most of the uses of the frame number field in the
frame_data structure.

Change-Id: Ie22e4533e87f8360d7c0a61ca6ffb796cc233f22
Reviewed-on: https://code.wireshark.org/review/13509
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-01-24 03:41:28 +00:00
AndersBroman 9b2f3f7c5c [BER] Fix Wireshark heap-based out-of-bounds read in dissect_ber_constrained_bitstring
Bug: 11828
Change-Id: I43c493ed261e73e0f3b31892c161dcfc46071054
Reviewed-on: https://code.wireshark.org/review/13292
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>
2016-01-14 20:23:38 +00:00