mirror of
https://github.com/samba-team/samba.git
synced 2025-01-03 01:18:10 +03:00
util/charset: Rename utf16_len_n() to utf16_null_terminated_len_n()
The new name indicates that — contrary to functions such as strnlen() — the length may include the terminator. Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
This commit is contained in:
parent
c2a743190f
commit
542e5a3039
@ -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:
|
||||
|
@ -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);
|
||||
/**
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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,
|
||||
|
@ -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) {
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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) {
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user