]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s4:librpc: Produce more helpful error message when bytes length is odd
authorJoseph Sutton <josephsutton@catalyst.net.nz>
Thu, 16 Nov 2023 23:56:17 +0000 (12:56 +1300)
committerAndrew Bartlett <abartlet@samba.org>
Mon, 20 Nov 2023 21:50:32 +0000 (21:50 +0000)
Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
source4/librpc/rpc/pyrpc_util.c

index 16d6905da7c61c5560273ed052b2b20b8c2887d6..98cfb73c1af59203df6ffe1f10b62f6ea3079e94 100644 (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)) {