aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors
diff options
context:
space:
mode:
authorPascal Quantin <pascal.quantin@gmail.com>2018-08-27 09:31:15 +0200
committerPascal Quantin <pascal.quantin@gmail.com>2018-08-27 08:46:03 +0000
commit1bf27192c90a10b947bff72ab9ab29426052cf9a (patch)
treead1fdd632b6565530d65809c33c9bc9587eaa9de /epan/dissectors
parent281936a5bed109f3ed4287d8d14ab410629f00f4 (diff)
Proxy: fix heuristic dissector
Ensure that at least 12 bytes were captured before trying to check the magic. Otherwise it can trigger an exception and prevent other heuristic dissectors from being called. Change-Id: Ib90febc208a69ae4e10c5c971e7cddfa7157c8a4 Reviewed-on: https://code.wireshark.org/review/29298 Petri-Dish: Pascal Quantin <pascal.quantin@gmail.com> Tested-by: Petri Dish Buildbot Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
Diffstat (limited to 'epan/dissectors')
-rw-r--r--epan/dissectors/packet-proxy.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/epan/dissectors/packet-proxy.c b/epan/dissectors/packet-proxy.c
index 8e24a4aa35..633e5df870 100644
--- a/epan/dissectors/packet-proxy.c
+++ b/epan/dissectors/packet-proxy.c
@@ -258,8 +258,9 @@ dissect_proxy_v2(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
static gboolean
dissect_proxy_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
{
- guint length = tvb_reported_length(tvb);
- if (length >= 16 && tvb_memeql(tvb, 0, proxy_v2_magic, sizeof(proxy_v2_magic)) == 0) {
+ if (tvb_reported_length(tvb) >= 16 &&
+ tvb_captured_length(tvb) >= sizeof(proxy_v2_magic) &&
+ tvb_memeql(tvb, 0, proxy_v2_magic, sizeof(proxy_v2_magic)) == 0) {
// TODO maybe check for "(hdr.v2.ver_cmd & 0xF0) == 0x20" as done in "9. Sample code" from
// https://www.haproxy.org/download/1.8/doc/proxy-protocol.txt?
dissect_proxy_v2(tvb, pinfo, tree, data);