From d1e5a6176c1191e46a22319d356fa93b0fee76f3 Mon Sep 17 00:00:00 2001 From: Joseph Sutton Date: Fri, 17 Nov 2023 12:56:17 +1300 Subject: [PATCH] s4:librpc: Produce more helpful error message when bytes length is odd Signed-off-by: Joseph Sutton Reviewed-by: Andrew Bartlett --- source4/librpc/rpc/pyrpc_util.c | 4 ++++ 1 file changed, 4 insertions(+) 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)) { -- 2.47.3