summaryrefslogtreecommitdiff
path: root/source4/librpc/ndr/libndr.h
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2004-12-09 07:05:00 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 13:06:27 -0500
commit74eb0017be0e89df7c0ce0a18a7042dc7d06bfdb (patch)
treef92ef13e0f4712f77852d2ba768e3b8b7d94a0a1 /source4/librpc/ndr/libndr.h
parent22f141166ad8f54282210699921a5de0b8436742 (diff)
downloadsamba-74eb0017be0e89df7c0ce0a18a7042dc7d06bfdb.tar.gz
samba-74eb0017be0e89df7c0ce0a18a7042dc7d06bfdb.tar.bz2
samba-74eb0017be0e89df7c0ce0a18a7042dc7d06bfdb.zip
r4110: fixed pidl to allow arrays to have size_is() and length_is() elements
that depend on variables that come after the array in the structure or function. This has been something that has been problematic for a while, but the winreg QueryValue problem finally prompted me to fix it properly. We should now go back and fix up all the ugly workarounds we have used to avoid this problem in other calls. Unfortunately the solution is fairly complex, and involves the use of the internal ndr token lists (similar to the solution for relative pointers). I wonder if anyone else will be able to follow the logic if I get run over by a bus :-) (This used to be commit e839b19ec5581f669f2a7705b1fb80845313251c)
Diffstat (limited to 'source4/librpc/ndr/libndr.h')
-rw-r--r--source4/librpc/ndr/libndr.h27
1 files changed, 10 insertions, 17 deletions
diff --git a/source4/librpc/ndr/libndr.h b/source4/librpc/ndr/libndr.h
index fe817bfdcd..bb28c3a23c 100644
--- a/source4/librpc/ndr/libndr.h
+++ b/source4/librpc/ndr/libndr.h
@@ -47,6 +47,8 @@ struct ndr_pull {
uint32_t offset;
struct ndr_token_list *relative_list;
+ struct ndr_token_list *array_size_list;
+ struct ndr_token_list *array_length_list;
/* this is used to ensure we generate unique reference IDs
between request and reply */
@@ -149,7 +151,8 @@ enum ndr_err_code {
NDR_ERR_VALIDATE,
NDR_ERR_BUFSIZE,
NDR_ERR_ALLOC,
- NDR_ERR_RANGE
+ NDR_ERR_RANGE,
+ NDR_ERR_TOKEN
};
/*
@@ -236,30 +239,20 @@ enum ndr_err_code {
#define NDR_ALLOC_N_SIZE(ndr, s, n, elsize) do { \
- if ((n) == 0) { \
- (s) = NULL; \
- } else { \
- (s) = talloc_array(ndr, elsize, n, __location__); \
- if (!(s)) return ndr_pull_error(ndr, \
- NDR_ERR_ALLOC, \
- "Alloc %u * %u failed\n", \
- n, elsize); \
- } \
- } while (0)
+ (s) = talloc_array(ndr, elsize, n, __location__); \
+ if (!(s)) return ndr_pull_error(ndr, NDR_ERR_ALLOC, "Alloc %u * %u failed\n", n, elsize); \
+} while (0)
#define NDR_ALLOC_N(ndr, s, n) NDR_ALLOC_N_SIZE(ndr, s, n, sizeof(*(s)))
#define NDR_PUSH_ALLOC_SIZE(ndr, s, size) do { \
- (s) = talloc(ndr, size); \
- if ((size) && !(s)) return ndr_push_error(ndr, NDR_ERR_ALLOC, \
- "push alloc %u failed\n",\
- size); \
- } while (0)
+ (s) = talloc(ndr, size); \
+ if (!(s)) return ndr_push_error(ndr, NDR_ERR_ALLOC, "push alloc %u failed\n", size); \
+} while (0)
#define NDR_PUSH_ALLOC(ndr, s) NDR_PUSH_ALLOC_SIZE(ndr, s, sizeof(*(s)))
-
/* these are used when generic fn pointers are needed for ndr push/pull fns */
typedef NTSTATUS (*ndr_push_fn_t)(struct ndr_push *, void *);
typedef NTSTATUS (*ndr_pull_fn_t)(struct ndr_pull *, void *);