librpc: Do not allow u16string to be encoded in a big‐endian context
authorJoseph Sutton <josephsutton@catalyst.net.nz>
Thu, 21 Dec 2023 20:58:53 +0000 (09:58 +1300)
committerAndrew Bartlett <abartlet@samba.org>
Thu, 21 Dec 2023 23:48:46 +0000 (23:48 +0000)
Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
librpc/ndr/ndr_string.c

index 89ba8b0579bbe8b3e439d437969e4800447ac2ea..323886b2fe5cbad4a9e3549cbdb0f60c295d7b1e 100644 (file)
@@ -491,6 +491,17 @@ _PUBLIC_ enum ndr_err_code ndr_pull_u16string(struct ndr_pull *ndr,
                return NDR_ERR_SUCCESS;
        }
 
+       if (NDR_BE(ndr)) {
+               /*
+                * It isn’t clear how this type should be encoded in a
+                * big‐endian context.
+                */
+               return ndr_pull_error(
+                       ndr,
+                       NDR_ERR_STRING,
+                       "u16string does not support big‐endian encoding\n");
+       }
+
        if (ndr->flags & LIBNDR_ENCODING_FLAGS) {
                return ndr_pull_error(
                        ndr,
@@ -552,6 +563,17 @@ _PUBLIC_ enum ndr_err_code ndr_push_u16string(struct ndr_push *ndr,
                return NDR_ERR_SUCCESS;
        }
 
+       if (NDR_BE(ndr)) {
+               /*
+                * It isn’t clear how this type should be encoded in a
+                * big‐endian context.
+                */
+               return ndr_push_error(
+                       ndr,
+                       NDR_ERR_STRING,
+                       "u16string does not support big‐endian encoding\n");
+       }
+
        if (s == NULL) {
                return ndr_push_error(
                        ndr,