diff options
author | Stefan Metzmacher <metze@samba.org> | 2011-03-08 10:14:51 +0100 |
---|---|---|
committer | Günther Deschner <gd@samba.org> | 2014-02-11 16:02:13 +0100 |
commit | e2a621466e740cc7fc2a659163f8895287c9a01e (patch) | |
tree | cc11efeb002f42e8f169cc153843ad334a1fdab9 | |
parent | 91b3e415d59feeb31a8255d147622a32e1bc64f1 (diff) | |
download | samba-e2a621466e740cc7fc2a659163f8895287c9a01e.tar.gz samba-e2a621466e740cc7fc2a659163f8895287c9a01e.tar.xz samba-e2a621466e740cc7fc2a659163f8895287c9a01e.zip |
librpc/ndr: add NDR_ERR_INCOMPLETE_BUFFER and LIBNDR_FLAG_INCOMPLETE_BUFFER
If we pull a pipe chunk we need a way to check if we
have enough bytes to parse the complete chunk.
Setting ndr_pull->flags |= LIBNDR_FLAG_INCOMPLETE_BUFFER
would change NDR_ERR_BUFSIZE (and later maybe others)
into NDR_ERR_INCOMPLETE_BUFFER.
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Guenther Deschner <gd@samba.org>
-rw-r--r-- | librpc/ndr/libndr.h | 11 | ||||
-rw-r--r-- | librpc/ndr/ndr.c | 10 |
2 files changed, 20 insertions, 1 deletions
diff --git a/librpc/ndr/libndr.h b/librpc/ndr/libndr.h index 8070c3cb56..bc843c12e2 100644 --- a/librpc/ndr/libndr.h +++ b/librpc/ndr/libndr.h @@ -124,6 +124,14 @@ struct ndr_print { #define LIBNDR_STRING_FLAGS (0x7FFC) /* + * don't debug NDR_ERR_BUFSIZE failures, + * as the available buffer might be incomplete. + * + * return NDR_ERR_INCOMPLETE_BUFFER instead. + */ +#define LIBNDR_FLAG_INCOMPLETE_BUFFER (1<<16) + +/* * This lets ndr_pull_subcontext_end() return * NDR_ERR_UNREAD_BYTES. */ @@ -206,7 +214,8 @@ enum ndr_err_code { NDR_ERR_INVALID_POINTER, NDR_ERR_UNREAD_BYTES, NDR_ERR_NDR64, - NDR_ERR_FLAGS + NDR_ERR_FLAGS, + NDR_ERR_INCOMPLETE_BUFFER }; #define NDR_ERR_CODE_IS_SUCCESS(x) (x == NDR_ERR_SUCCESS) diff --git a/librpc/ndr/ndr.c b/librpc/ndr/ndr.c index 3ed0310a63..99e9fe4d8f 100644 --- a/librpc/ndr/ndr.c +++ b/librpc/ndr/ndr.c @@ -453,6 +453,15 @@ _PUBLIC_ enum ndr_err_code ndr_pull_error(struct ndr_pull *ndr, va_list ap; int ret; + if (ndr->flags & LIBNDR_FLAG_INCOMPLETE_BUFFER) { + switch (ndr_err) { + case NDR_ERR_BUFSIZE: + return NDR_ERR_INCOMPLETE_BUFFER; + default: + break; + } + } + va_start(ap, format); ret = vasprintf(&s, format, ap); va_end(ap); @@ -1510,6 +1519,7 @@ const static struct { { NDR_ERR_INVALID_POINTER, "Invalid Pointer" }, { NDR_ERR_UNREAD_BYTES, "Unread Bytes" }, { NDR_ERR_NDR64, "NDR64 assertion error" }, + { NDR_ERR_INCOMPLETE_BUFFER, "Incomplete Buffer" }, { 0, NULL } }; |