1
0
mirror of https://github.com/samba-team/samba.git synced 2025-02-28 01:58:17 +03:00

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>
This commit is contained in:
Stefan Metzmacher 2011-03-08 10:14:51 +01:00 committed by Günther Deschner
parent 91b3e415d5
commit e2a621466e
2 changed files with 20 additions and 1 deletions

View File

@ -123,6 +123,14 @@ struct ndr_print {
#define LIBNDR_FLAG_STR_RAW8 (1<<13)
#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)

View File

@ -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 }
};