1
0
mirror of https://github.com/samba-team/samba.git synced 2025-03-12 20:58:37 +03:00

r3073: Fix bug in the handling of null-terminated ASCII strings in RPC.

Because we didn't count the null terminator, we would not move past it
in the packet.

Andrew Bartlett
This commit is contained in:
Andrew Bartlett 2004-10-20 02:02:00 +00:00 committed by Gerald (Jerry) Carter
parent 834b09929b
commit 8b38bffc70
2 changed files with 19 additions and 1 deletions

View File

@ -1119,6 +1119,24 @@ int strcmp_safe(const char *s1, const char *s2)
}
/*******************************************************************
return the number of bytes occupied by a buffer in ASCII format
the result includes the null termination
limited by 'n' bytes
********************************************************************/
size_t ascii_len_n(const char *src, size_t n)
{
size_t len;
len = strnlen(src, n);
if (len+1 <= n) {
len += 1;
}
return len;
}
/*******************************************************************
Return a string representing a CIFS attribute for a file.
********************************************************************/

View File

@ -657,7 +657,7 @@ NTSTATUS ndr_pull_string(struct ndr_pull *ndr, int ndr_flags, const char **s)
case LIBNDR_FLAG_STR_NULLTERM:
if (byte_mul == 1) {
len1 = strnlen(ndr->data+ndr->offset, ndr->data_size - ndr->offset);
len1 = ascii_len_n(ndr->data+ndr->offset, ndr->data_size - ndr->offset);
} else {
len1 = utf16_len_n(ndr->data+ndr->offset, ndr->data_size - ndr->offset);
}