1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-22 13:34:15 +03:00

s4:librpc: Produce more helpful error message when bytes length is odd

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
This commit is contained in:
Joseph Sutton 2023-11-17 12:56:17 +13:00 committed by Andrew Bartlett
parent 4629fc7c61
commit d1e5a6176c

View File

@ -447,6 +447,10 @@ uint16_t *PyUtf16String_FromBytes(TALLOC_CTX *mem_ctx, PyObject *value)
PyErr_SetString(PyExc_ValueError, "bytes length is negative");
return NULL;
}
if (len & 1) {
PyErr_SetString(PyExc_ValueError, "bytes length is odd");
return NULL;
}
/* Ensure that the bytes object contains no embedded null terminator. */
if ((size_t)len != utf16_len_n(bytes, len)) {