1
0
mirror of https://github.com/samba-team/samba.git synced 2025-08-28 09:49:30 +03:00

librpc/ndr: avoid alignment allocation in ndr_push_DATA_BLOB()

Pair-Programmed-With: Volker Lendecke <vl@samba.org>

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
This commit is contained in:
Stefan Metzmacher
2024-08-29 13:26:04 +02:00
committed by Volker Lendecke
parent df103890f9
commit 664eb19343

View File

@ -1404,18 +1404,23 @@ _PUBLIC_ void ndr_print_DATA_BLOB(struct ndr_print *ndr, const char *name, DATA_
*/
_PUBLIC_ enum ndr_err_code ndr_push_DATA_BLOB(struct ndr_push *ndr, ndr_flags_type ndr_flags, DATA_BLOB blob)
{
static const uint8_t padding[8] = { 0, };
if (ndr->flags & LIBNDR_FLAG_REMAINING) {
/* nothing to do */
} else if (ndr->flags & (LIBNDR_ALIGN_FLAGS & ~LIBNDR_FLAG_NOALIGN)) {
blob.data = discard_const_p(uint8_t, padding);
if (ndr->flags & LIBNDR_FLAG_ALIGN2) {
blob.length = NDR_ALIGN(ndr, 2);
} else if (ndr->flags & LIBNDR_FLAG_ALIGN4) {
blob.length = NDR_ALIGN(ndr, 4);
} else if (ndr->flags & LIBNDR_FLAG_ALIGN8) {
blob.length = NDR_ALIGN(ndr, 8);
} else {
return ndr_push_error(ndr,
NDR_ERR_LENGTH,
"Invalid align flags");
}
NDR_PUSH_ALLOC_SIZE(ndr, blob.data, blob.length);
data_blob_clear(&blob);
} else {
NDR_CHECK(ndr_push_uint3264(ndr, NDR_SCALARS, blob.length));
}