diff --git a/lib/tdr/tdr.c b/lib/tdr/tdr.c index 6c87aa0b89d..cff1fc67d5e 100644 --- a/lib/tdr/tdr.c +++ b/lib/tdr/tdr.c @@ -148,7 +148,7 @@ NTSTATUS tdr_pull_charset(struct tdr_pull *tdr, TALLOC_CTX *ctx, const char **v, length = ascii_len_n((const char*)tdr->data.data+tdr->offset, tdr->data.length-tdr->offset); break; case CH_UTF16: - length = utf16_len_n(tdr->data.data+tdr->offset, tdr->data.length-tdr->offset); + length = utf16_null_terminated_len_n(tdr->data.data+tdr->offset, tdr->data.length-tdr->offset); break; default: diff --git a/lib/util/charset/charset.h b/lib/util/charset/charset.h index e8dec6ae0d6..df8aa0de862 100644 --- a/lib/util/charset/charset.h +++ b/lib/util/charset/charset.h @@ -114,7 +114,7 @@ return the number of bytes occupied by a buffer in CH_UTF16 format the result includes the null termination limited by 'n' bytes **/ -size_t utf16_len_n(const void *src, size_t n); +size_t utf16_null_terminated_len_n(const void *src, size_t n); char *strchr_m(const char *s, char c); /** diff --git a/lib/util/charset/util_unistr.c b/lib/util/charset/util_unistr.c index 3a6c48f3749..260692aceac 100644 --- a/lib/util/charset/util_unistr.c +++ b/lib/util/charset/util_unistr.c @@ -209,7 +209,7 @@ return the number of bytes occupied by a buffer in CH_UTF16 format the result includes the null termination limited by 'n' bytes **/ -size_t utf16_len_n(const void *src, size_t n) +size_t utf16_null_terminated_len_n(const void *src, size_t n) { size_t len; @@ -503,7 +503,7 @@ static size_t pull_ucs2(char *dest, const void *src, size_t dest_len, size_t src if (src_len == (size_t)-1) { src_len = utf16_len(src); } else { - src_len = utf16_len_n(src, src_len); + src_len = utf16_null_terminated_len_n(src, src_len); } } diff --git a/libcli/smb/smbXcli_base.c b/libcli/smb/smbXcli_base.c index a3079fc41e9..c2dece8ca0a 100644 --- a/libcli/smb/smbXcli_base.c +++ b/libcli/smb/smbXcli_base.c @@ -4615,8 +4615,8 @@ static void smbXcli_negprot_smb1_done(struct tevent_req *subreq) if (blob1.length > 0) { size_t len; - len = utf16_len_n(blob1.data, - blob1.length); + len = utf16_null_terminated_len_n(blob1.data, + blob1.length); blob1.length = len; ok = convert_string_talloc(state, @@ -4733,8 +4733,8 @@ static void smbXcli_negprot_smb1_done(struct tevent_req *subreq) size_t len; bool ok; - len = utf16_len_n(blob1.data, - blob1.length); + len = utf16_null_terminated_len_n(blob1.data, + blob1.length); blob1.length = len; ok = convert_string_talloc(state, diff --git a/libcli/smb/util.c b/libcli/smb/util.c index 6e29a98dc40..baae532b55a 100644 --- a/libcli/smb/util.c +++ b/libcli/smb/util.c @@ -392,7 +392,7 @@ static NTSTATUS internal_bytes_pull_str(TALLOC_CTX *mem_ctx, char **_str, buf += offset; if (ucs2) { - buf_len = utf16_len_n(buf, buf_len); + buf_len = utf16_null_terminated_len_n(buf, buf_len); } else { size_t tmp = strnlen((const char *)buf, buf_len); if (tmp < buf_len) { diff --git a/librpc/ndr/ndr_string.c b/librpc/ndr/ndr_string.c index bb157b08492..1f7bfff2e71 100644 --- a/librpc/ndr/ndr_string.c +++ b/librpc/ndr/ndr_string.c @@ -147,7 +147,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_string(struct ndr_pull *ndr, ndr_flags_type conv_src_len = ascii_len_n((const char *)(ndr->data+ndr->offset), ndr->data_size - ndr->offset); } else { NDR_PULL_NEED_BYTES(ndr, 2); - conv_src_len = utf16_len_n(ndr->data+ndr->offset, ndr->data_size - ndr->offset); + conv_src_len = utf16_null_terminated_len_n(ndr->data+ndr->offset, ndr->data_size - ndr->offset); } byte_mul = 1; /* the length is now absolute */ break; diff --git a/source4/libcli/ldap/ldap_controls.c b/source4/libcli/ldap/ldap_controls.c index 2d45f2c1ac0..a1d421b296f 100644 --- a/source4/libcli/ldap/ldap_controls.c +++ b/source4/libcli/ldap/ldap_controls.c @@ -461,7 +461,7 @@ static bool decode_verify_name_request(void *mem_ctx, DATA_BLOB in, void *_out) } if (name.length) { - len = utf16_len_n(name.data, name.length); + len = utf16_null_terminated_len_n(name.data, name.length); convert_string_talloc(mem_ctx, CH_UTF16, CH_UNIX, name.data, len, &lvnc->gc, &lvnc->gc_len); diff --git a/source4/libcli/raw/rawrequest.c b/source4/libcli/raw/rawrequest.c index 0b58fe9b3f8..1c72bc2c9a2 100644 --- a/source4/libcli/raw/rawrequest.c +++ b/source4/libcli/raw/rawrequest.c @@ -612,7 +612,7 @@ static size_t smbcli_req_pull_ucs2(struct request_bufinfo *bufinfo, TALLOC_CTX * src_len = byte_len; } - src_len2 = utf16_len_n(src, src_len); + src_len2 = utf16_null_terminated_len_n(src, src_len); /* ucs2 strings must be at least 2 bytes long */ if (src_len2 < 2) { @@ -815,7 +815,7 @@ size_t smbcli_blob_pull_ucs2(TALLOC_CTX* mem_ctx, return 0; } - src_len2 = utf16_len_n(src, src_len); + src_len2 = utf16_null_terminated_len_n(src, src_len); ret = convert_string_talloc(mem_ctx, CH_UTF16, CH_UNIX, src, src_len2, (void **)&dest2, &ret_size); if (!ret) { diff --git a/source4/smb_server/smb/request.c b/source4/smb_server/smb/request.c index 05981424f16..47cfd3243c4 100644 --- a/source4/smb_server/smb/request.c +++ b/source4/smb_server/smb/request.c @@ -507,7 +507,7 @@ static size_t req_pull_ucs2(struct request_bufinfo *bufinfo, const char **dest, return 0; } - src_len2 = utf16_len_n(src, src_len); + src_len2 = utf16_null_terminated_len_n(src, src_len); if (src_len2 == 0) { *dest = talloc_strdup(bufinfo->mem_ctx, ""); return src_len2 + alignment;