summaryrefslogtreecommitdiff
path: root/epan/dissectors/packet-ssl-utils.c
diff options
context:
space:
mode:
authorPeter Wu <peter@lekensteyn.nl>2016-09-24 15:11:32 +0200
committerMichael Mann <mmann78@netscape.net>2016-09-25 00:39:25 +0000
commit75ae538514f55f8faa114ce31fc5a2a1d7b7ef22 (patch)
tree5aa69a9810c910021ef001686ae2a886133dfbe5 /epan/dissectors/packet-ssl-utils.c
parent46aba5a3407be21db89fff8ed3be4bed4883e806 (diff)
downloadwireshark-75ae538514f55f8faa114ce31fc5a2a1d7b7ef22.tar.gz
ssl: fix exact matching of ALPN protocol names
The "name_length >= alpn_proto->proto_name_len" condition always failed to match for short names (like "h2" where the reported length is 2, but the proto_name_len would be 3). This fixes recognition of HTTP/2 traffic, without this patch it would be interpreted as http-over-tls as reported on https://ask.wireshark.org/questions/55720/how-to-install-http2-dissector-plugin Change-Id: Idc3eae0b6d593c8f3c435230ef76da90a4b1e7fc Reviewed-on: https://code.wireshark.org/review/17907 Petri-Dish: Alexis La Goutte <alexis.lagoutte@gmail.com> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Michael Mann <mmann78@netscape.net>
Diffstat (limited to 'epan/dissectors/packet-ssl-utils.c')
-rw-r--r--epan/dissectors/packet-ssl-utils.c21
1 files changed, 11 insertions, 10 deletions
diff --git a/epan/dissectors/packet-ssl-utils.c b/epan/dissectors/packet-ssl-utils.c
index dc0f01016c..aab0f1feca 100644
--- a/epan/dissectors/packet-ssl-utils.c
+++ b/epan/dissectors/packet-ssl-utils.c
@@ -1239,20 +1239,20 @@ const value_string tls_cert_status_type[] = {
* "byte strings MUST NOT be truncated" (RFC 7301) */
typedef struct ssl_alpn_protocol {
const char *proto_name;
- size_t proto_name_len;
+ gboolean match_exact;
const char *dissector_name;
} ssl_alpn_protocol_t;
/* http://www.iana.org/assignments/tls-extensiontype-values/tls-extensiontype-values.xhtml#alpn-protocol-ids */
static const ssl_alpn_protocol_t ssl_alpn_protocols[] = {
- { "http/1.1", sizeof("http/1.1"), "http" },
+ { "http/1.1", TRUE, "http" },
/* SPDY moves so fast, just 1, 2 and 3 are registered with IANA but there
* already exists 3.1 as of this writing... match the prefix. */
- { "spdy/", sizeof("spdy/") - 1, "spdy" },
- { "stun.turn", sizeof("stun.turn"), "turnchannel" },
- { "stun.nat-discovery", sizeof("stun.nat-discovery"), "stun" },
+ { "spdy/", FALSE, "spdy" },
+ { "stun.turn", TRUE, "turnchannel" },
+ { "stun.nat-discovery", TRUE, "stun" },
/* draft-ietf-httpbis-http2-16 */
- { "h2-", sizeof("h2-") - 1, "http2" }, /* draft versions */
- { "h2", sizeof("h2"), "http2" }, /* final version */
+ { "h2-", FALSE, "http2" }, /* draft versions */
+ { "h2", TRUE, "http2" }, /* final version */
};
/* Lookup tables }}} */
@@ -5364,9 +5364,10 @@ ssl_dissect_hnd_hello_ext_alpn(ssl_common_dissect_t *hf, tvbuff_t *tvb,
for (i = 0; i < G_N_ELEMENTS(ssl_alpn_protocols); i++) {
const ssl_alpn_protocol_t *alpn_proto = &ssl_alpn_protocols[i];
- if (name_length >= alpn_proto->proto_name_len &&
- (memcmp(proto_name, alpn_proto->proto_name,
- alpn_proto->proto_name_len) == 0)) {
+ if ((alpn_proto->match_exact &&
+ name_length == strlen(alpn_proto->proto_name) &&
+ !strcmp(proto_name, alpn_proto->proto_name)) ||
+ (!alpn_proto->match_exact && g_str_has_prefix(proto_name, alpn_proto->proto_name))) {
dissector_handle_t handle;
/* ProtocolName match, so set the App data dissector handle.