aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-smb.c
diff options
context:
space:
mode:
authorJohn Thacker <johnthacker@gmail.com>2022-10-03 21:45:02 -0400
committerJohn Thacker <johnthacker@gmail.com>2022-10-04 17:23:17 -0400
commit9de534b8c6642ffbe89b1ff76d980deab49187b7 (patch)
treecaa67bbedb6bbaf3d0a17e0b70286745527dc54a /epan/dissectors/packet-smb.c
parent0046163269e69fc8ad124ef507cfc65fc33a17b5 (diff)
smb: Get the dialect name as ENC_ASCII
The dialect name is technically an OEM string, in the local OEM Extended ASCII DOS code page, but in practice there are no known dialect names that use anything outside of ASCII. We don't know what the local OEM code page is, anyway. tvb_get_const_stringz does no translation into UTF-8, and should only be used in rare instances. Fix #18401.
Diffstat (limited to 'epan/dissectors/packet-smb.c')
-rw-r--r--epan/dissectors/packet-smb.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/epan/dissectors/packet-smb.c b/epan/dissectors/packet-smb.c
index 9cbccf6a13..ec97a57eab 100644
--- a/epan/dissectors/packet-smb.c
+++ b/epan/dissectors/packet-smb.c
@@ -2794,7 +2794,15 @@ dissect_negprot_request(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int
/* XXX - what if this runs past bc? */
tvb_ensure_bytes_exist(tvb, offset+1, 1);
- str = tvb_get_const_stringz(tvb, offset+1, &len);
+
+ /* XXX: This is an OEM String according to MS-CIFS and
+ * should use the local OEM (extended ASCII DOS) code page,
+ * It doesn't appear than any known dialect strings use
+ * anything outside ASCII, though.
+ *
+ * There could be a dissector preference for local code page.
+ */
+ str = tvb_get_stringz_enc(pinfo->pool, tvb, offset+1, &len, ENC_ASCII);
if (tr) {
dit = proto_tree_add_string(tr, hf_smb_dialect, tvb, offset, len+1, str);
@@ -2809,8 +2817,8 @@ dissect_negprot_request(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int
/*Dialect Name */
CHECK_BYTE_COUNT(len);
- proto_tree_add_string(dtr, hf_smb_dialect_name, tvb, offset,
- len, str);
+ proto_tree_add_item(dtr, hf_smb_dialect_name, tvb,
+ offset, len, ENC_ASCII);
COUNT_BYTES(len);
if (!pinfo->fd->visited && dialects && (dialects->num < MAX_DIALECTS)) {