diff options
Diffstat (limited to 'librpc')
-rw-r--r-- | librpc/ndr/libndr.h | 2 | ||||
-rw-r--r-- | librpc/ndr/ndr.c | 34 |
2 files changed, 36 insertions, 0 deletions
diff --git a/librpc/ndr/libndr.h b/librpc/ndr/libndr.h index 64c858d950e..8c59bb9bb06 100644 --- a/librpc/ndr/libndr.h +++ b/librpc/ndr/libndr.h @@ -469,6 +469,8 @@ enum ndr_err_code ndr_check_array_size(struct ndr_pull *ndr, void *p, uint32_t s enum ndr_err_code ndr_pull_array_length(struct ndr_pull *ndr, const void *p); uint32_t ndr_get_array_length(struct ndr_pull *ndr, const void *p); enum ndr_err_code ndr_check_array_length(struct ndr_pull *ndr, void *p, uint32_t length); +enum ndr_err_code ndr_push_pipe_chunk_trailer(struct ndr_push *ndr, int ndr_flags, uint32_t count); +enum ndr_err_code ndr_check_pipe_chunk_trailer(struct ndr_pull *ndr, int ndr_flags, uint32_t count); enum ndr_err_code ndr_push_set_switch_value(struct ndr_push *ndr, const void *p, uint32_t val); enum ndr_err_code ndr_pull_set_switch_value(struct ndr_pull *ndr, const void *p, uint32_t val); enum ndr_err_code ndr_print_set_switch_value(struct ndr_print *ndr, const void *p, uint32_t val); diff --git a/librpc/ndr/ndr.c b/librpc/ndr/ndr.c index cfeb2314878..56d1fab05e4 100644 --- a/librpc/ndr/ndr.c +++ b/librpc/ndr/ndr.c @@ -829,6 +829,40 @@ _PUBLIC_ enum ndr_err_code ndr_check_array_length(struct ndr_pull *ndr, void *p, return NDR_ERR_SUCCESS; } +_PUBLIC_ enum ndr_err_code ndr_push_pipe_chunk_trailer(struct ndr_push *ndr, int ndr_flags, uint32_t count) +{ + if (ndr->flags & LIBNDR_FLAG_NDR64) { + int64_t tmp = 0 - (int64_t)count; + uint64_t ncount = tmp; + + NDR_CHECK(ndr_push_hyper(ndr, ndr_flags, ncount)); + } + + return NDR_ERR_SUCCESS; +} + +_PUBLIC_ enum ndr_err_code ndr_check_pipe_chunk_trailer(struct ndr_pull *ndr, int ndr_flags, uint32_t count) +{ + if (ndr->flags & LIBNDR_FLAG_NDR64) { + int64_t tmp = 0 - (int64_t)count; + uint64_t ncount1 = tmp; + uint64_t ncount2; + + NDR_CHECK(ndr_pull_hyper(ndr, ndr_flags, &ncount2)); + if (ncount1 == ncount2) { + return NDR_ERR_SUCCESS; + } + + return ndr_pull_error(ndr, NDR_ERR_ARRAY_SIZE, + "Bad pipe trailer[%lld should be %lld] size was %lu\"", + (unsigned long long)ncount2, + (unsigned long long)ncount1, + (unsigned long)count); + } + + return NDR_ERR_SUCCESS; +} + /* store a switch value */ |