From 54dd7bccd29e98ff634196b7028261b998172d4e Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 3 Sep 2004 12:58:19 +0000 Subject: r2206: another (untested) attempt to make RELATIVE_CURRENT work for volker, plus removed unused ndr_pull_relative() function once volker commits a test for this I'll be able to ensure it really works as expected (This used to be commit 8ffe136ad2be52f3504d73ead0785c9c5f5d8770) --- source4/librpc/ndr/ndr.c | 46 ++++++---------------------------------------- 1 file changed, 6 insertions(+), 40 deletions(-) diff --git a/source4/librpc/ndr/ndr.c b/source4/librpc/ndr/ndr.c index 2f1c9ef47f..020ebb689c 100644 --- a/source4/librpc/ndr/ndr.c +++ b/source4/librpc/ndr/ndr.c @@ -620,45 +620,6 @@ void ndr_push_struct_end(struct ndr_push *ndr) { } - -/* - pull a relative structure -*/ -NTSTATUS ndr_pull_relative(struct ndr_pull *ndr, const void **buf, size_t size, - NTSTATUS (*fn)(struct ndr_pull *, int ndr_flags, void *)) -{ - struct ndr_pull *ndr2; - uint32_t ofs; - struct ndr_pull_save save; - void *p; - - NDR_ALLOC(ndr, ndr2); - NDR_CHECK(ndr_pull_uint32(ndr, &ofs)); - if (ofs == 0) { - (*buf) = NULL; - return NT_STATUS_OK; - } - ndr_pull_save(ndr, &save); - if (ndr->flags & LIBNDR_FLAG_RELATIVE_CURRENT) { - NDR_CHECK(ndr_pull_set_offset(ndr, ofs + ndr->offset - 4)); - } else { - NDR_CHECK(ndr_pull_set_offset(ndr, ofs)); - } - NDR_CHECK(ndr_pull_subcontext(ndr, ndr2, ndr->data_size - ndr->offset)); - /* strings must be allocated by the backend functions */ - if (ndr->flags & LIBNDR_STRING_FLAGS) { - NDR_CHECK(fn(ndr2, NDR_SCALARS|NDR_BUFFERS, &p)); - } else { - NDR_ALLOC_SIZE(ndr, p, size); - NDR_CHECK(fn(ndr2, NDR_SCALARS|NDR_BUFFERS, p)); - } - (*buf) = p; - ndr_pull_restore(ndr, &save); - talloc_free(ndr2); - return NT_STATUS_OK; -} - - /* store a token in the ndr context, for later retrieval */ @@ -700,7 +661,12 @@ static uint32_t ndr_token_retrieve(struct ndr_token_list **list, const void *key */ NTSTATUS ndr_pull_relative1(struct ndr_pull *ndr, const void *p, uint32_t rel_offset) { - return ndr_token_store(ndr, &ndr->relative_list, p, rel_offset); + if (ndr->flags & LIBNDR_FLAG_RELATIVE_CURRENT) { + return ndr_token_store(ndr, &ndr->relative_list, p, + rel_offset + ndr->offset); + } else { + return ndr_token_store(ndr, &ndr->relative_list, p, rel_offset); + } } /* -- cgit