aboutsummaryrefslogtreecommitdiffstats
path: root/epan
diff options
context:
space:
mode:
authorGerald Combs <gerald@wireshark.org>2013-02-25 04:16:37 +0000
committerGerald Combs <gerald@wireshark.org>2013-02-25 04:16:37 +0000
commit977730ed7c4ca0a3696357fd3c04aea5814b4d22 (patch)
treea3db9db736c0a38d4a570bce9726ee84e28b4054 /epan
parent1c9c5621c8472f62f744f8fc26936702397b4b8f (diff)
The IEEE may not care what's in an SSID but Pango is much more picky.
If the SSID isn't valid UTF-8 truncate it and indicate that we did so. (As bug 5738 points out this is part of a more general problem but in the meantime this keeps us from crashing.) Don't try to decrypt too-long SSIDs. I feel compelled to change my SSID at home to a series of carriage returns, linefeeds, and SNOWMAN (U+2603). svn path=/trunk/; revision=47871
Diffstat (limited to 'epan')
-rw-r--r--epan/dissectors/packet-ieee80211.c30
1 files changed, 23 insertions, 7 deletions
diff --git a/epan/dissectors/packet-ieee80211.c b/epan/dissectors/packet-ieee80211.c
index e248841c3c..33efacc621 100644
--- a/epan/dissectors/packet-ieee80211.c
+++ b/epan/dissectors/packet-ieee80211.c
@@ -9224,21 +9224,37 @@ ieee80211_tag_ssid(packet_info *pinfo, proto_tree *tree,
guint32 tag_len, tvbuff_t *tvb, int offset)
{
/* 7.3.2.1 SSID element (0) */
- guint8 *ssid; /* The SSID may consist of arbitrary bytes */
+ gchar *ssid; /* The SSID may consist of arbitrary bytes */
+ const gchar *ssid_end;
+ gint ssid_len = tag_len;
if (beacon_padding != 0) /* padding bug */
return offset;
- if (tag_len > MAX_SSID_LEN) {
+ if (ssid_len > MAX_SSID_LEN) {
expert_add_info_format(pinfo, ti_len, PI_MALFORMED, PI_ERROR,
"SSID length (%u) greater than maximum (%u)",
- tag_len, MAX_SSID_LEN);
+ ssid_len, MAX_SSID_LEN);
+ ssid_len = MAX_SSID_LEN;
+ }
+
+ ssid = tvb_get_ephemeral_string(tvb, offset + 2, ssid_len);
+ if (ssid_len == (gint)tag_len) {
+ AirPDcapSetLastSSID(&airpdcap_ctx, (CHAR *) ssid, ssid_len);
+ }
+ g_utf8_validate(ssid, ssid_len, &ssid_end);
+ ssid[ssid_end - ssid] = '\0';
+ if ((gint)(ssid_end - ssid) == ssid_len) {
+ proto_tree_add_item(tree, hf_ieee80211_tag_ssid, tvb, offset + 2, tag_len,
+ ENC_ASCII|ENC_NA);
+ } else {
+ emem_strbuf_t *ssid_sb = ep_strbuf_new(ssid);
+ ep_strbuf_append(ssid_sb, " [truncated]");
+ proto_tree_add_string_format_value(tree, hf_ieee80211_tag_ssid, tvb, offset + 2, tag_len,
+ ssid, "%s", ssid_sb->str);
+ ssid = ssid_sb->str;
}
- ssid = tvb_get_ephemeral_string(tvb, offset + 2, tag_len);
- AirPDcapSetLastSSID(&airpdcap_ctx, (CHAR *) ssid, tag_len);
- proto_tree_add_item(tree, hf_ieee80211_tag_ssid, tvb, offset + 2, tag_len,
- ENC_ASCII|ENC_NA);
if (tag_len > 0) {
proto_item_append_text(ti, ": %s", ssid);