From: Joseph Sutton Date: Thu, 16 Nov 2023 23:56:17 +0000 (+1300) Subject: s4:librpc: Produce more helpful error message when bytes length is odd X-Git-Tag: talloc-2.4.2~617 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=d1e5a6176c1191e46a22319d356fa93b0fee76f3;p=thirdparty%2Fsamba.git s4:librpc: Produce more helpful error message when bytes length is odd Signed-off-by: Joseph Sutton Reviewed-by: Andrew Bartlett --- diff --git a/source4/librpc/rpc/pyrpc_util.c b/source4/librpc/rpc/pyrpc_util.c index 16d6905da7c..98cfb73c1af 100644 --- a/source4/librpc/rpc/pyrpc_util.c +++ b/source4/librpc/rpc/pyrpc_util.c @@ -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)) {