From: Volker Lendecke Date: Mon, 30 Sep 2024 10:07:30 +0000 (+0200) Subject: libndr: Simplify data flow in ndr_push_relative_ptr2 X-Git-Tag: tdb-1.4.13~564 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5d19591e756beac70d022cecc6bb5d791ba67655;p=thirdparty%2Fsamba.git libndr: Simplify data flow in ndr_push_relative_ptr2 Consolidate saving/replacing ndr->offset right around the push_uint32 Signed-off-by: Volker Lendecke Reviewed-by: Ralph Boehme --- diff --git a/librpc/ndr/ndr.c b/librpc/ndr/ndr.c index e552ccba20f..e96f50a3f2a 100644 --- a/librpc/ndr/ndr.c +++ b/librpc/ndr/ndr.c @@ -1726,19 +1726,23 @@ static enum ndr_err_code ndr_push_relative_ptr2(struct ndr_push *ndr, const void if (p == NULL) { return NDR_ERR_SUCCESS; } - save_offset = ndr->offset; + if (ndr->offset < ndr->relative_base_offset) { + return ndr_push_error( + ndr, + NDR_ERR_BUFSIZE, + "ndr_push_relative_ptr2 ndr->offset(%" PRIu32 ") " + "< ndr->relative_base_offset(%" PRIu32 ")", + ndr->offset, + ndr->relative_base_offset); + } NDR_CHECK(ndr_token_retrieve(&ndr->relative_list, p, &ptr_offset)); if (ptr_offset > ndr->offset) { return ndr_push_error(ndr, NDR_ERR_BUFSIZE, "ndr_push_relative_ptr2 ptr_offset(%"PRIu32") > ndr->offset(%"PRIu32")", ptr_offset, ndr->offset); } + save_offset = ndr->offset; ndr->offset = ptr_offset; - if (save_offset < ndr->relative_base_offset) { - return ndr_push_error(ndr, NDR_ERR_BUFSIZE, - "ndr_push_relative_ptr2 save_offset(%"PRIu32") < ndr->relative_base_offset(%"PRIu32")", - save_offset, ndr->relative_base_offset); - } NDR_CHECK(ndr_push_uint32(ndr, NDR_SCALARS, save_offset - ndr->relative_base_offset)); ndr->offset = save_offset; return NDR_ERR_SUCCESS;