Commit Graph

130 Commits

Author SHA1 Message Date
Jan Romann 252e667218 CoAP: update Observe option doc comment 2023-02-06 20:47:12 +00:00
Jan Romann be591c150a CoAP: add support for additional options 2023-02-06 20:47:12 +00:00
Jan Romann 0dbf8c8e6c CoAP: Add support for more Content-Formats 2023-02-05 20:41:18 +00:00
Gerald Combs 9754448044 CoAP+RTPS: Initialize some variables
Fix

    ==10365== Conditional jump or move depends on uninitialised value(s)
    ==10365==    at 0x81514B4: get_hfi_length (epan/proto.c:5981)
    ==10365==    by 0x815A0A5: proto_tree_add_pi (epan/proto.c:5953)
    ==10365==    by 0x815F41B: proto_tree_add_uint64 (epan/proto.c:5542)
    ==10365==    by 0x6BF362C: dissect_msg_tag (epan/dissectors/packet-cose.c:462)
    ==10365==    by 0x6BF1A27: dissect_cose_mac (epan/dissectors/packet-cose.c:656)
    ==10365==    by 0x813511A: call_dissector_through_handle (epan/packet.c:757)
    ==10365==    by 0x8130E58: call_dissector_work (epan/packet.c:850)
    ==10365==    by 0x8131604: dissector_try_string_new (epan/packet.c:1751)
    ==10365==    by 0x8131686: dissector_try_string (epan/packet.c:1776)
    ==10365==    by 0x6BD8C60: dissect_coap_payload (epan/dissectors/packet-coap.c:1115)
    ==10365==    by 0x6BDAD34: dissect_coap_message (epan/dissectors/packet-coap.c:1403)
    ==10365==    by 0x6BD8ECB: dissect_coap (epan/dissectors/packet-coap.c:1526)
    ==10365==
    ==10365== Conditional jump or move depends on uninitialised value(s)
    ==10365==    at 0x81517EC: get_hfi_length (epan/proto.c:6115)
    ==10365==    by 0x815A0A5: proto_tree_add_pi (epan/proto.c:5953)
    ==10365==    by 0x815F41B: proto_tree_add_uint64 (epan/proto.c:5542)
    ==10365==    by 0x6BF362C: dissect_msg_tag (epan/dissectors/packet-cose.c:462)
    ==10365==    by 0x6BF1A27: dissect_cose_mac (epan/dissectors/packet-cose.c:656)
    ==10365==    by 0x813511A: call_dissector_through_handle (epan/packet.c:757)
    ==10365==    by 0x8130E58: call_dissector_work (epan/packet.c:850)
    ==10365==    by 0x8131604: dissector_try_string_new (epan/packet.c:1751)
    ==10365==    by 0x8131686: dissector_try_string (epan/packet.c:1776)
    ==10365==    by 0x6BD8C60: dissect_coap_payload (epan/dissectors/packet-coap.c:1115)
    ==10365==    by 0x6BDAD34: dissect_coap_message (epan/dissectors/packet-coap.c:1403)
    ==10365==    by 0x6BD8ECB: dissect_coap (epan/dissectors/packet-coap.c:1526)

and

    ==10365== Conditional jump or move depends on uninitialised value(s)
    ==10365==    at 0x748EB90: hash_by_guid (epan/dissectors/packet-rtps.c:6006)
    ==10365==    by 0xC522FD5: wmem_map_lookup (wsutil/wmem/wmem_map.c:264)
    ==10365==    by 0x74A2E33: rtps_util_detect_coherent_set_end_empty_data_case (epan/dissectors/packet-rtps.c:3294)
    ==10365==    by 0x74A1054: dissect_RTPS_DATA (epan/dissectors/packet-rtps.c:10829)
    ==10365==    by 0x748E606: dissect_rtps_submessage_v2 (epan/dissectors/packet-rtps.c:12064)
    ==10365==    by 0x748DFBE: dissect_rtps_submessages (epan/dissectors/packet-rtps.c:12439)
    ==10365==    by 0x74A3FC9: dissect_rtps (epan/dissectors/packet-rtps.c:12357)
    ==10365==    by 0x748EDD2: dissect_rtps_udp (epan/dissectors/packet-rtps.c:12459)
    ==10365==    by 0x81334CA: dissector_try_heuristic (epan/packet.c:2864)
    ==10365==    by 0x76A8FF6: decode_udp_ports (epan/dissectors/packet-udp.c:712)
    ==10365==    by 0x76AB875: dissect (epan/dissectors/packet-udp.c:1267)
    ==10365==    by 0x76A9DAD: dissect_udp (epan/dissectors/packet-udp.c:1273)

Fixes #18785
2023-01-13 13:21:24 -08:00
João Valverde 32f88ad22c wmem: Remove strbuf max size parameter
This parameter was introduced as a safeguard for bugs
that generate an unbounded string but its utility for
that purpose is doubtful and the way it is being used
creates problems with invalid truncation of UTF-8
strings.

Rename wmem_strbuf_sized_new() with a better name.
2022-12-03 01:54:52 +00:00
Guy Harris 8724c249e1 coap, thread: special-case application/octet-stream for CoAP for TMF.
Have a "CoAP for TMF" dissector that the user can use Decode As to
assign to a UDP port.

Have a "coap_tmf_media_type" dissector table in which the TMF code can
register itself for the media type "application/octet-stream".

Have the "CoAP for TMF" dissector pass a "this is for TMF" flag to the
common dissection code.  In the common dissection code, if that flag is
set, first try the media type with the "coap_tmf_media_type" dissector
table before trying it in the regular "media_type" table.

This allows a user to specify UDP ports that 1) should be decoded as
CoAP and 2) should have an application/octet-stream payload dissected as
a TMF message, which should address concerns raised for Thread in issue
2022-09-13 19:47:58 +00:00
Guy Harris ede58da465 coap: have different dissectors for different transports.
As noted in the comment for e5951765d8,
mechanisms by which a dissector can attempt to infer the protocol over
which its protocol was transported aren't reliable.

To add to that, another failure case for inferring it from the previous
entry in the pinfo->layers list is a packet transported over TCP using
MPTCP, as the previous entry would be MPTCP, not TCP.

So we provide multiple CoAP dissectors:

 - CoAP over WebSockets;
 - CoAP over TCP, TLS, or other byte-stream protocols;
 - CoAP over other transports;

and have them pass the transport type to a common dissection routine.

We then register the appropriate dissectors in various dissector tables,
and register the CoAP-over-other-transports dissector as the "coap"
dissector.
2022-09-11 19:16:03 -07:00
Guy Harris 8195bdd340 Rename a bunch of things with "conversation".
A conversation in Wireshark might have two endpoints or might have no
endpoints; few if any have one endpoint.  Distinguish between
conversations and endpoints.
2022-08-25 20:02:20 -07:00
Stig Bjørlykke ad7905e8da coap: Use correct conversation_new() options
Fix conversation_new() options after they was changed/improved
in commit 709593ee.
2022-06-07 16:35:58 +00:00
Stig Bjørlykke 16871f66d7 coap: Change text format used in COL_INFO
Change to use format_text() and format_text_string() on strings
used in COL_INFO to explicitly show '\n' and such.
2022-04-03 12:07:33 +02:00
Stig Bjørlykke e6202cf1d9 coap: Format text used in COL_INFO
Use format_text_wsp() on strings from packet used in COL_INFO to
show non-printable characters as C-style escapes.
2022-04-01 12:42:58 +02:00
João Valverde 22ee2764a7 Replace g_snprintf() with snprintf() (dissectors)
Use macros from inttypes.h with format strings.
2021-12-19 20:25:11 +00:00
Jan Romann f3dbfa3bdf coap: add missing content-format mappings 2021-09-21 01:14:33 +00:00
Stig Bjørlykke 1807d3874a coap: Do not handle Accept as Content-Format
Only use value of Content-Format to dissect the content in the
current packet. Accept is used to tell which format is expected
in the reply.

Fixes: #17536
2021-08-20 08:12:44 +00:00
David Perry 34ee3cbc48 Change some `wmem_packet_scope()` to `pinfo->pool`
As requested [here][1], help with replacing calls to
`wmem_packet_scope()` with references to `pinfo->pool`.

My principles were:

* Plugins chosen semi-randomly.
* When a calling function already has a `pinfo` argument, just use that.
    * Remove `_U_` from its signature if it was there.
* Don't go more than 2 or 3 levels deep of changing signatures.
* If a function is clearly allocing memory to return, change the
  function signature to take a `wmem_allocator_t *`. Otherwise, either
  that or take a `packet_info *` as seems to make sense.
* No mention of `wmem_packet_scope()` should remain in the files I've
  touched.
    * I didn't always succeed at this, but I made a dent.

[1]: https://www.wireshark.org/lists/wireshark-dev/202107/msg00052.html
2021-07-29 01:36:01 +00:00
João Valverde 133b0c583f Move epan/wmem/wmem_scopes.h to epan/
This header was installed incorrectly to epan/wmem_scopes.h.

Instead of creating additional installation rules for a single
header in a subfolder (kept for backward compatibility) just
rename the standard "epan/wmem/wmem.h" include to
"epan/wmem_scopes.h" and fix the documentation.

Now the header is installed *correctly* to epan/wmem_scopes.h.
2021-07-26 14:56:11 +00:00
Stig Bjørlykke db966fdd2f coap: Do retransmission detection only for CON and NON
Only do retransmission detection for CON and NON type messages.

Change-Id: I5b5d93800918a98d4d321d1dcd0f3090b485ba9e
Reviewed-on: https://code.wireshark.org/review/37842
Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2020-07-13 05:14:18 +00:00
Stig Bjørlykke f0f2480f3c coap: Add Hop-Limit Option
Add Hop-Limit Option from RFC 8768.

Change-Id: I029cd1528f6cfdb87e8c259d2169633a72f1f418
Reviewed-on: https://code.wireshark.org/review/37640
Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org>
Tested-by: Petri Dish Buildbot
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
2020-07-01 18:40:02 +00:00
Stig Bjørlykke 4af7888cae coap: Fix "End of Block #" indication
The M bit is used in Block1 Option in a request and in Block2 Option
in a response. Use this to determine when to prefix the block number
information with "End of".

Change-Id: I11c741b15f97f68d668d6cbec97660a6ea392dc1
Reviewed-on: https://code.wireshark.org/review/37629
Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2020-07-01 08:17:54 +00:00
Stig Bjørlykke 40f3c393c3 coap: Move dissection of payload before state tracking
Change-Id: Icd8bce0a12167cc3edb3cb70fad5dd696af0b796
Reviewed-on: https://code.wireshark.org/review/37623
Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org>
Tested-by: Petri Dish Buildbot
Reviewed-by: Stig Bjørlykke <stig@bjorlykke.org>
2020-06-30 21:09:38 +00:00
Stig Bjørlykke 90d63ba075 coap: Add items for block payload and block length
Add items for block_payload and block_length to be used for block
analysis when reassembly is not complete.

Change-Id: I969cac9a50903431c727a2fc424eca464f0167d7
Reviewed-on: https://code.wireshark.org/review/37622
Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org>
Tested-by: Petri Dish Buildbot
Reviewed-by: Stig Bjørlykke <stig@bjorlykke.org>
2020-06-30 21:09:21 +00:00
Stig Bjørlykke 2dcf32bc9c coap: Mark private and vendor-specific options as unknown
Any private or vendor-specific options are not invalid, so mark them
as unknown. Move expert info to option entry. Add the unknown option
number to the item.

Change-Id: I567c397787d4afddffdca407a8c2e39db828ab83
Reviewed-on: https://code.wireshark.org/review/37562
Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org>
Tested-by: Petri Dish Buildbot
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2020-06-27 13:48:16 +00:00
Stig Bjørlykke d3845de256 coap: Add block reassembly
Reassemble blocks before passing to payload dissector.

Change-Id: I09d81abe016989c8d705355a117cf12e40f07e59
Reviewed-on: https://code.wireshark.org/review/37440
Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org>
Tested-by: Petri Dish Buildbot
Reviewed-by: Stig Bjørlykke <stig@bjorlykke.org>
2020-06-11 06:37:41 +00:00
Stig Bjørlykke 86c6befcab coap: Fix "More Flag" value
Use the raw value for the block "More Flag", not the already adjusted one.

Change-Id: I13ddd24c4f9b9201798d18abe008945879f03774
Reviewed-on: https://code.wireshark.org/review/37442
Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org>
Tested-by: Petri Dish Buildbot
Reviewed-by: Stig Bjørlykke <stig@bjorlykke.org>
2020-06-11 06:36:55 +00:00
Mališa Vučinić 5aaec7f16d oscore: Update to RFC8613.
-Update dissection of the OSCORE option.
-Enable zero-length Sender and Recipient ID.
-Add ID Context field in preferences.
-Update context derivation to rfc8613.
-Extend context lookup to include ID context.
-Fix Observe responses.

Bug: 16585
Change-Id: Ib9823a54cf535be3559e1c41a19b8b612458777f
Reviewed-on: https://code.wireshark.org/review/37314
Petri-Dish: Alexis La Goutte <alexis.lagoutte@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2020-05-27 06:59:47 +00:00
Pascal Quantin 75e1b69e88 CoAP: change detection logic for CoAP over TCP or TLS
Do not assume that having a TCP port means that CoAP is running directly
over TCP: this is not the case with MQTT for example (see bug 14591 for
a capture). Instead explicitly check that the parent dissector is TCP or
TLS.

Bug: 15910
Change-Id: Ib4880623b8525fe6be52a685397005eac86da135
Reviewed-on: https://code.wireshark.org/review/35879
Petri-Dish: Pascal Quantin <pascal@wireshark.org>
Tested-by: Petri Dish Buildbot
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
2020-01-21 22:09:51 +00:00
Cenk Gündoğan 5199a61e79 coap: use correct OSCORE option type
The current implementation assumes a wrong OSCORE option type
"21". RFC 8613 was release in July 2019 and defines an OSCORE option
type of "9". See: https://tools.ietf.org/html/rfc8613#section-2

Change-Id: I5fea8dffc2d1586f891b2b3b9fa42183b138e0ab
Reviewed-on: https://code.wireshark.org/review/35163
Reviewed-by: Pascal Quantin <pascal@wireshark.org>
Petri-Dish: Pascal Quantin <pascal@wireshark.org>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2019-11-21 11:31:34 +00:00
Pascal Quantin f75f128462 CoAP: add a separator between messages in info column
Ping-Bug: 15910
Change-Id: I9845ded5986565328c5228b8a6e6f9aed0a98166
Reviewed-on: https://code.wireshark.org/review/35011
Reviewed-by: Pascal Quantin <pascal@wireshark.org>
Petri-Dish: Pascal Quantin <pascal@wireshark.org>
Tested-by: Petri Dish Buildbot
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
2019-11-07 12:13:25 +00:00
Pascal Quantin 5db18c604e CoAP: fixes for TCP transport
- switch from tcp_dissect_pdus() to pinfo based reassembly as the header
size is variable
- use the proper message length when dissecting the payload
- reuse the conversation from the TCP disector instead of creating a new
one and breaking the TCP analysis

Ping-Bug: 15910
Change-Id: Ie2689363a01343bbb45cba6a48ce3475521954ec
Reviewed-on: https://code.wireshark.org/review/34987
Petri-Dish: Pascal Quantin <pascal@wireshark.org>
Tested-by: Petri Dish Buildbot
Reviewed-by: Stig Bjørlykke <stig@bjorlykke.org>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2019-11-05 17:09:40 +00:00
Stig Bjørlykke a7838d9403 coap: Distinguish observe option for request and response
The observe option has different values for request and response. For
request it identifies register or deregister, and for response it is a
sequence number for reordering detection. RFC 7641 chapter 2.

Change-Id: I09515864997a32f7259e344532ea770b74030b04
Reviewed-on: https://code.wireshark.org/review/34368
Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org>
Tested-by: Petri Dish Buildbot
Reviewed-by: Michael Mann <mmann78@netscape.net>
2019-08-26 17:26:15 +00:00
Stig Bjørlykke d966c0dd5e coap: Improve request/response tracking
Use both Token and Message ID in request/response tracking and retransmission
detection. The token is the same when using observables but the message id is
increasing.

Change-Id: I545416ce139328e6a8eb67258d7b51bddb6b278e
Reviewed-on: https://code.wireshark.org/review/34367
Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org>
Tested-by: Petri Dish Buildbot
Reviewed-by: Michael Mann <mmann78@netscape.net>
2019-08-26 17:24:36 +00:00
Peter Wu 1da2caa0e0 CoAP: add frame support for CoAP over TCP, TLS, WebSockets (RFC 8323)
Support is limited to message framing.

Bug: 15910
Change-Id: Ia27c0b8428842618af00720441a9ef9cf163fecb
Reviewed-on: https://code.wireshark.org/review/34001
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2019-07-19 06:12:09 +00:00
Peter Wu 8499ad93c5 CoAP: add CoAP Signalling Codes (RFC 8323)
Update names and RFC references based on the IANA registry at
https://www.iana.org/assignments/core-parameters/core-parameters.xhtml

Bug: 15910
Change-Id: I56a4cc3c23fee321b09547254a33f6a76d46cc9d
Reviewed-on: https://code.wireshark.org/review/34002
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
2019-07-18 07:34:04 +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
Stig Bjørlykke d916e0741a coap: Add retransmission detection
Show as expert info and in info column. Link to first request/response.

Change-Id: I990d9a5aec5904dabe22bcb103426a8549cef31b
Reviewed-on: https://code.wireshark.org/review/32615
Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2019-03-29 04:42:38 +00:00
Uli Heilmeier 7ef8ddcad4 CoAP: Add RFC8516 response code
RFC8516 adds new response code 4.29

Change-Id: I4a1d57a0632939d0b59a7f625720d07be3cdb866
Reviewed-on: https://code.wireshark.org/review/31719
Reviewed-by: Anders Broman <a.broman58@gmail.com>
Petri-Dish: Anders Broman <a.broman58@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
2019-01-24 22:14:27 +00:00
Stig Bjørlykke 01c8397fd1 coap: Add request/response arrows
Change-Id: I72393548f5a51e60f516c0999c8a779e75d0c14a
Reviewed-on: https://code.wireshark.org/review/31093
Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org>
Tested-by: Petri Dish Buildbot
Reviewed-by: Stig Bjørlykke <stig@bjorlykke.org>
2018-12-18 13:15:13 +00:00
Peter Wu 5a2aafef7a coap: ensure that piv_len matches piv
In frame 121, piv_len was 1 while piv was NULL. Ensure that both piv and
piv_len are reset to avoid this. Adjust another check to ensure that piv
and piv_len are in sync (probably not necessary, but it seems the
intention).

Bug: 15172
Change-Id: If8636d32f3273d6707749c807bd7d676ca9ab96d
Fixes: v2.5.2rc0-9-g830ea5731a ("CoAP: Hooks to OSCORE")
Reviewed-on: https://code.wireshark.org/review/30100
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Petri-Dish: Gerald Combs <gerald@wireshark.org>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-10-10 04:57:38 +00:00
Guy Harris aa6d5ee1a7 Use the time stamps in the packet_info structure, not the frame_data structure.
In the long run, we'd like to remove the time stamp from the frame_data
structure, as, in Wireshark, and in TShark in two-pass mode, there's one
allocated for every frame in the file, and shrinking the size of that
structure reduces the memory usage.

This removes one obstacle to that.

Change-Id: Ia8f87522cd974555c57e0ac1e742b097e8b0f2fc
Reviewed-on: https://code.wireshark.org/review/29881
Reviewed-by: Guy Harris <guy@alum.mit.edu>
2018-09-26 20:34:21 +00:00
Stig Bjørlykke abc1f64576 coap: Use proto_tree_add_item for strings in the packet
Change from proto_tree_add_string() to proto_tree_add_item() for strings
which is fetched from the packet.

Change-Id: Iae6538977b2ecf69f83c62b47ac02198f5f09d54
Reviewed-on: https://code.wireshark.org/review/29348
Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-08-30 12:07:59 +00:00
Jaap Keuter b9c18a4188 CoAP: handle per packet data properly
Bug: 14966
Change-Id: I9c5c1da923a0cc2881465bcc484850d042a314d6
Signed-off-by: Jaap Keuter <jaap.keuter@xs4all.nl>
Reviewed-on: https://code.wireshark.org/review/28694
Tested-by: Petri Dish Buildbot
Reviewed-by: Roland Knall <rknall@gmail.com>
2018-07-13 08:50:27 +00:00
Stig Bjørlykke 1bdc98936f coap: Revert "Store ctype values in transaction tracking"
This change was based on a incomplete/incorrect implementation of
LwM2M and is not correct because the payload encoding is mandatory
in the response.

This reverts commit 46fcf452ac.
This reverts commit b1e0cb01b3.

Change-Id: I89ae1f84e2735ad049a0f7c9045175940bed25cb
Reviewed-on: https://code.wireshark.org/review/27770
Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org>
Tested-by: Petri Dish Buildbot
Reviewed-by: Stig Bjørlykke <stig@bjorlykke.org>
2018-05-24 10:38:11 +00:00
Stig Bjørlykke 171d92cc14 lwm2mtlv: Add Resource name tables
Add one fixed table for OMA (Normative) defined resource names and
one table for user defined resource names. All resources are identified
by a object ID and a resource ID.

Show number of elements in arrays instead of number of bytes.

Next iteration will add proper hf entries for OMA elements.

Change-Id: I4d6c053a7c448cc65692ba1d1e92a2033ff3b397
Reviewed-on: https://code.wireshark.org/review/27551
Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-05-15 10:30:18 +00:00
Peter Wu b1e0cb01b3 coap: fix use-after-free of "coinfo->ctype_str"
A use-after-free is possible through the following path:

    // returns wmem_packet_scope() memory
    coinfo->ctype_str = val_to_str(coinfo->ctype_value, vals_ctype, "Unknown Type %u");
    // leaks packet scoped memory into conversation
    coap_trans = wmem_new0(wmem_file_scope(), coap_transaction);
    coap_trans->req_ctype_str = coinfo->ctype_str;  // <-- oops
    // next packet: use-after-free of packet scoped memory
    coinfo->ctype_str = coap_trans->req_ctype_str;

This could be fixed by duplicating "ctype_str" with wmem_file_scope, but
since all "ctype_str" strings are constant, make the problematic
"ctype_str" assignment also constant for unknown types (the numeric type
is also stored in "ctype_value" if necessary).

Change-Id: I6249e076fa282bbe0982b8c709788e27f6fdf86e
Fixes: v2.9.0rc0-317-g46fcf452ac ("coap: Store ctype values in transaction tracking")
Link: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=8196
Reviewed-on: https://code.wireshark.org/review/27477
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2018-05-13 12:02:37 +00:00
Stig Bjørlykke 46fcf452ac coap: Store ctype values in transaction tracking
Transfer ctype values from GET request to response to be able
to decode the payload correctly.

Change-Id: Ida7598aefbd3f245dd487d50562539395f130ac4
Reviewed-on: https://code.wireshark.org/review/27163
Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org>
Tested-by: Petri Dish Buildbot
Reviewed-by: Roland Knall <rknall@gmail.com>
2018-04-26 15:03:29 +00:00
Mališa Vučinić 093efd9c30 OSCORE: Decrypt responses and dissect plaintext with CoAP functions
Add support for decrypting Observe responses with Partial IV within the
response. CoAP prioritizes the Partial IV from the response if present,
if not it passes Partial IV from the corresponding request.

Bug: 14417
Change-Id: Icb0f782de67bd0507db4f1f2a2ea90c72a4b6f0a
Reviewed-on: https://code.wireshark.org/review/25483
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
2018-03-16 15:02:48 +00:00
Mališa Vučinić de9a4ff91f CoAP: Refactor code, option and payload dissection
OSCORE plaintext contains CoAP code, some CoAP options and CoAP payload.
To avoid code duplication, CoAP dissection of these fields used by
OSCORE is generalized and exported in packet-coap.h. Exported functions
and their subroutines now operate explicitly on local variables. This
allows OSCORE dissector to pass its header fields.

Use of "offset_end" instead of "coap_length" to denote the end of
message.

Bug: 14417
Change-Id: If51b0d585ab29d46c1c550fbf264fd3765ed4c32
Reviewed-on: https://code.wireshark.org/review/25482
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
2018-03-16 15:02:36 +00:00
Mališa Vučinić 830ea5731a CoAP: Hooks to OSCORE
Structure oscore_info_t carries parameters needed by OSCORE for
decryption. These parameters are communicated in the CoAP layer within
the Object-Security option. To decrypt a response, OSCORE needs the
parameters from the corresponding request. Matching of responses to
requests on the CoAP layer is leveraged to pass the correct parameters
to OSCORE. This change adds an oscore_info_t pointer to coap_info and
coap_transaction structures in order to pass the parameters on to the
OSCORE dissector. Dissection of Object-Security option is reworked to
make  use of the new coap_info element, instead of relying on local
variables.

Bug: 14417
Change-Id: I173057ba95407675aaa539ddbff51d02337551bc
Reviewed-on: https://code.wireshark.org/review/25481
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
2018-03-16 15:02:26 +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
Stig Bjørlykke d86f820206 coap: Change Uri-Path from hidden to generated
This field is generated so mark it so.  It may also be usable so
make it visible.

Change-Id: I10d951f234f1fba240059bc791b40d25dede07a9
Reviewed-on: https://code.wireshark.org/review/25350
Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org>
Tested-by: Petri Dish Buildbot
Reviewed-by: Alexis La Goutte <alexis.lagoutte@gmail.com>
2018-01-17 14:10:44 +00:00