From 9de534b8c6642ffbe89b1ff76d980deab49187b7 Mon Sep 17 00:00:00 2001 From: John Thacker Date: Mon, 3 Oct 2022 21:45:02 -0400 Subject: 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. --- epan/dissectors/packet-smb.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'epan/dissectors/packet-smb.c') 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)) { -- cgit v1.2.3