diff options
author | Guy Harris <guy@alum.mit.edu> | 2013-12-19 09:19:33 +0000 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2013-12-19 09:19:33 +0000 |
commit | 317b82898664af0f0fe71c513995bb137d0a3c57 (patch) | |
tree | 37b1f0304675d62189eebd6faaa8d8383eba893e | |
parent | 4a346b71882c782cf070e382a4bf718150b192d8 (diff) |
Use proto_tree_add_item() or tvb_get_string_enc() instead of
tvb_get_unicode_string(). If there's an indication that the encoding is
UCS-2, use that, otherwise use UTF-16. (For example, "BMP" stands for
"Basic Multilingual Plane", which is the part of Unicode that can be
encoded in 16 bits, hence UCS-2.)
In the description of the "Use Heuristics for UDP" preference for the
XML dissector, note that it's not just trying to recognize XML in UCS-2,
it's trying to recognize XML in *big-endian* UCS-2.
svn path=/trunk/; revision=54245
-rw-r--r-- | asn1/x509sat/x509sat.cnf | 2 | ||||
-rw-r--r-- | epan/dissectors/packet-kerberos.c | 5 | ||||
-rw-r--r-- | epan/dissectors/packet-ndps.c | 4 | ||||
-rw-r--r-- | epan/dissectors/packet-per.c | 5 | ||||
-rw-r--r-- | epan/dissectors/packet-ptpip.c | 2 | ||||
-rw-r--r-- | epan/dissectors/packet-x509sat.c | 2 | ||||
-rw-r--r-- | epan/dissectors/packet-xml.c | 6 |
7 files changed, 12 insertions, 14 deletions
diff --git a/asn1/x509sat/x509sat.cnf b/asn1/x509sat/x509sat.cnf index bbeab761e3..b1044fe89f 100644 --- a/asn1/x509sat/x509sat.cnf +++ b/asn1/x509sat/x509sat.cnf @@ -385,7 +385,7 @@ XDayOf/fifth fifth_dayof if (! wide_tvb) { return offset; } - string = tvb_get_unicode_string (wmem_packet_scope(), wide_tvb, 0, tvb_length(wide_tvb), ENC_BIG_ENDIAN); + string = tvb_get_string_enc (wmem_packet_scope(), wide_tvb, 0, tvb_length(wide_tvb), ENC_UCS_2|ENC_BIG_ENDIAN); proto_item_append_text(actx->created_item, " %s", string); #.END diff --git a/epan/dissectors/packet-kerberos.c b/epan/dissectors/packet-kerberos.c index 9b36e756d8..366f477dd1 100644 --- a/epan/dissectors/packet-kerberos.c +++ b/epan/dissectors/packet-kerberos.c @@ -2793,13 +2793,13 @@ dissect_krb5_PAC_PRIVSVR_CHECKSUM(proto_tree *parent_tree, tvbuff_t *tvb, int of return offset; } +/* See [MS-PAC] */ static int dissect_krb5_PAC_CLIENT_INFO_TYPE(proto_tree *parent_tree, tvbuff_t *tvb, int offset, asn1_ctx_t *actx _U_) { proto_item *item=NULL; proto_tree *tree=NULL; guint16 namelen; - char *name; item=proto_tree_add_item(parent_tree, hf_krb_PAC_CLIENT_INFO_TYPE, tvb, offset, tvb_length_remaining(tvb, offset), ENC_NA); if(parent_tree){ @@ -2816,8 +2816,7 @@ dissect_krb5_PAC_CLIENT_INFO_TYPE(proto_tree *parent_tree, tvbuff_t *tvb, int of offset+=2; /* client name */ - name=tvb_get_unicode_string(wmem_packet_scope(), tvb, offset, namelen, ENC_LITTLE_ENDIAN); - proto_tree_add_string(tree, hf_krb_pac_clientname, tvb, offset, namelen, name); + proto_tree_add_item(tree, hf_krb_pac_clientname, tvb, offset, namelen, ENC_UTF_16|ENC_LITTLE_ENDIAN); offset+=namelen; return offset; diff --git a/epan/dissectors/packet-ndps.c b/epan/dissectors/packet-ndps.c index a7e80f1b87..bfb20afde0 100644 --- a/epan/dissectors/packet-ndps.c +++ b/epan/dissectors/packet-ndps.c @@ -2068,12 +2068,12 @@ ndps_string(tvbuff_t* tvb, int hfinfo, proto_tree *ndps_tree, int offset, char * /* * ASCII. */ - string = tvb_get_string(wmem_packet_scope(), tvb, foffset, str_length); + string = tvb_get_string_enc(wmem_packet_scope(), tvb, foffset, str_length, ENC_ASCII|ENC_NA); /* XXX - extended ASCII? */; } else { /* * Unicode. */ - string = tvb_get_unicode_string(wmem_packet_scope(), tvb, foffset, str_length, ENC_LITTLE_ENDIAN); + string = tvb_get_string_enc(wmem_packet_scope(), tvb, foffset, str_length, ENC_UTF_16|ENC_LITTLE_ENDIAN); } foffset += str_length; proto_tree_add_string(ndps_tree, hfinfo, tvb, offset, str_length + 4, string); diff --git a/epan/dissectors/packet-per.c b/epan/dissectors/packet-per.c index dc9467926a..cdc5e449e9 100644 --- a/epan/dissectors/packet-per.c +++ b/epan/dissectors/packet-per.c @@ -785,7 +785,6 @@ guint32 dissect_per_BMPString(tvbuff_t *tvb, guint32 offset, asn1_ctx_t *actx, proto_tree *tree, int hf_index, int min_len, int max_len, gboolean has_extension _U_) { guint32 length; - static char *str; /* xx.x if the length is 0 bytes there will be no encoding */ if(max_len==0){ @@ -816,9 +815,7 @@ dissect_per_BMPString(tvbuff_t *tvb, guint32 offset, asn1_ctx_t *actx, proto_tre length=1024; } - str = tvb_get_unicode_string(wmem_packet_scope(), tvb, offset>>3, length*2, ENC_BIG_ENDIAN); - - proto_tree_add_string(tree, hf_index, tvb, offset>>3, length*2, str); + proto_tree_add_item(tree, hf_index, tvb, offset>>3, length*2, ENC_UCS_2|ENC_BIG_ENDIAN); offset+=(length<<3)*2; diff --git a/epan/dissectors/packet-ptpip.c b/epan/dissectors/packet-ptpip.c index ce654bc8aa..9548d62b30 100644 --- a/epan/dissectors/packet-ptpip.c +++ b/epan/dissectors/packet-ptpip.c @@ -865,7 +865,7 @@ void dissect_ptpIP_unicode_name(tvbuff_t *tvb, packet_info *pinfo, proto_tree *t gint nameLen; nameLen = tvb_unicode_strsize(tvb, *offset); - name = tvb_get_unicode_string(wmem_packet_scope(), tvb, *offset, nameLen, ENC_LITTLE_ENDIAN); + name = tvb_get_string_enc(wmem_packet_scope(), tvb, *offset, nameLen, ENC_UTF_16|ENC_LITTLE_ENDIAN); proto_tree_add_string(tree, hf_ptpIP_name, tvb, *offset, nameLen, name); *offset += nameLen; col_append_fstr( diff --git a/epan/dissectors/packet-x509sat.c b/epan/dissectors/packet-x509sat.c index da46bed587..8841404ed8 100644 --- a/epan/dissectors/packet-x509sat.c +++ b/epan/dissectors/packet-x509sat.c @@ -1519,7 +1519,7 @@ dissect_x509sat_SyntaxBMPString(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, in if (! wide_tvb) { return offset; } - string = tvb_get_unicode_string (wmem_packet_scope(), wide_tvb, 0, tvb_length(wide_tvb), ENC_BIG_ENDIAN); + string = tvb_get_string_enc (wmem_packet_scope(), wide_tvb, 0, tvb_length(wide_tvb), ENC_UCS_2|ENC_BIG_ENDIAN); proto_item_append_text(actx->created_item, " %s", string); diff --git a/epan/dissectors/packet-xml.c b/epan/dissectors/packet-xml.c index cf857d947d..9a28a1f727 100644 --- a/epan/dissectors/packet-xml.c +++ b/epan/dissectors/packet-xml.c @@ -238,7 +238,8 @@ static gboolean dissect_xml_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree * dissect_xml(tvb, pinfo, tree); return TRUE; } else if (pref_heuristic_unicode) { - const guint8 *data_str = tvb_get_unicode_string(NULL, tvb, 0, tvb_length(tvb), ENC_LITTLE_ENDIAN); + /* XXX - UCS-2, or UTF-16? */ + const guint8 *data_str = tvb_get_string_enc(NULL, tvb, 0, tvb_length(tvb), ENC_UCS_2|ENC_LITTLE_ENDIAN); tvbuff_t *unicode_tvb = tvb_new_child_real_data(tvb, data_str, tvb_length(tvb)/2, tvb_length(tvb)/2); tvb_set_free_cb(unicode_tvb, g_free); if (tvbparse_peek(tvbparse_init(unicode_tvb, 0, -1, NULL, want_ignore), want_heur)) { @@ -1476,8 +1477,9 @@ proto_register_xml(void) prefs_register_bool_preference(xml_module, "heuristic_udp", "Use Heuristics for UDP", "Try to recognize XML for unknown UDP ports", &pref_heuristic_udp); + /* XXX - UCS-2, or UTF-16? */ prefs_register_bool_preference(xml_module, "heuristic_unicode", "Use Unicode in heuristics", - "Try to recognize XML encoded in Unicode (UCS-2)", + "Try to recognize XML encoded in Unicode (UCS-2BE)", &pref_heuristic_unicode); g_array_free(ett_arr, TRUE); |