summaryrefslogtreecommitdiff
path: root/librpc/ndr
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2011-09-07 15:34:20 +1000
committerAndrew Tridgell <tridge@samba.org>2011-09-08 03:35:27 +0200
commita19fd96ab87290cd6ed1c93cd8f83e8697592b21 (patch)
treeb11158d41798bd55bd5135a26404f00413897a53 /librpc/ndr
parent1c25f5ebca7eb4e8a6ce95b1adf6088d67aecb94 (diff)
downloadsamba-a19fd96ab87290cd6ed1c93cd8f83e8697592b21.tar.gz
samba-a19fd96ab87290cd6ed1c93cd8f83e8697592b21.tar.bz2
samba-a19fd96ab87290cd6ed1c93cd8f83e8697592b21.zip
libndr: add checking to all pull/push functions of base types
this checks that the passed in ndr_flags are valid Pair-Programmed-With: Andrew Bartlett <abartlet@samba.org>
Diffstat (limited to 'librpc/ndr')
-rw-r--r--librpc/ndr/ndr_basic.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/librpc/ndr/ndr_basic.c b/librpc/ndr/ndr_basic.c
index b4443003d0..ab234bf5ca 100644
--- a/librpc/ndr/ndr_basic.c
+++ b/librpc/ndr/ndr_basic.c
@@ -61,6 +61,7 @@ _PUBLIC_ void ndr_check_padding(struct ndr_pull *ndr, size_t n)
*/
_PUBLIC_ enum ndr_err_code ndr_pull_int8(struct ndr_pull *ndr, int ndr_flags, int8_t *v)
{
+ NDR_PULL_CHECK_FLAGS(ndr, ndr_flags);
NDR_PULL_NEED_BYTES(ndr, 1);
*v = (int8_t)CVAL(ndr->data, ndr->offset);
ndr->offset += 1;
@@ -72,6 +73,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_int8(struct ndr_pull *ndr, int ndr_flags, in
*/
_PUBLIC_ enum ndr_err_code ndr_pull_uint8(struct ndr_pull *ndr, int ndr_flags, uint8_t *v)
{
+ NDR_PULL_CHECK_FLAGS(ndr, ndr_flags);
NDR_PULL_NEED_BYTES(ndr, 1);
*v = CVAL(ndr->data, ndr->offset);
ndr->offset += 1;
@@ -83,6 +85,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_uint8(struct ndr_pull *ndr, int ndr_flags, u
*/
_PUBLIC_ enum ndr_err_code ndr_pull_int16(struct ndr_pull *ndr, int ndr_flags, int16_t *v)
{
+ NDR_PULL_CHECK_FLAGS(ndr, ndr_flags);
NDR_PULL_ALIGN(ndr, 2);
NDR_PULL_NEED_BYTES(ndr, 2);
*v = (uint16_t)NDR_SVAL(ndr, ndr->offset);
@@ -95,6 +98,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_int16(struct ndr_pull *ndr, int ndr_flags, i
*/
_PUBLIC_ enum ndr_err_code ndr_pull_uint16(struct ndr_pull *ndr, int ndr_flags, uint16_t *v)
{
+ NDR_PULL_CHECK_FLAGS(ndr, ndr_flags);
NDR_PULL_ALIGN(ndr, 2);
NDR_PULL_NEED_BYTES(ndr, 2);
*v = NDR_SVAL(ndr, ndr->offset);
@@ -107,6 +111,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_uint16(struct ndr_pull *ndr, int ndr_flags,
*/
_PUBLIC_ enum ndr_err_code ndr_pull_uint1632(struct ndr_pull *ndr, int ndr_flags, uint16_t *v)
{
+ NDR_PULL_CHECK_FLAGS(ndr, ndr_flags);
if (unlikely(ndr->flags & LIBNDR_FLAG_NDR64)) {
uint32_t v32 = 0;
enum ndr_err_code err = ndr_pull_uint32(ndr, ndr_flags, &v32);
@@ -125,6 +130,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_uint1632(struct ndr_pull *ndr, int ndr_flags
*/
_PUBLIC_ enum ndr_err_code ndr_pull_int32(struct ndr_pull *ndr, int ndr_flags, int32_t *v)
{
+ NDR_PULL_CHECK_FLAGS(ndr, ndr_flags);
NDR_PULL_ALIGN(ndr, 4);
NDR_PULL_NEED_BYTES(ndr, 4);
*v = NDR_IVALS(ndr, ndr->offset);
@@ -137,6 +143,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_int32(struct ndr_pull *ndr, int ndr_flags, i
*/
_PUBLIC_ enum ndr_err_code ndr_pull_uint32(struct ndr_pull *ndr, int ndr_flags, uint32_t *v)
{
+ NDR_PULL_CHECK_FLAGS(ndr, ndr_flags);
NDR_PULL_ALIGN(ndr, 4);
NDR_PULL_NEED_BYTES(ndr, 4);
*v = NDR_IVAL(ndr, ndr->offset);
@@ -151,6 +158,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_uint3264(struct ndr_pull *ndr, int ndr_flags
{
uint64_t v64;
enum ndr_err_code err;
+ NDR_PULL_CHECK_FLAGS(ndr, ndr_flags);
if (likely(!(ndr->flags & LIBNDR_FLAG_NDR64))) {
return ndr_pull_uint32(ndr, ndr_flags, v);
}
@@ -169,6 +177,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_uint3264(struct ndr_pull *ndr, int ndr_flags
*/
_PUBLIC_ enum ndr_err_code ndr_pull_double(struct ndr_pull *ndr, int ndr_flags, double *v)
{
+ NDR_PULL_CHECK_FLAGS(ndr, ndr_flags);
NDR_PULL_ALIGN(ndr, 8);
NDR_PULL_NEED_BYTES(ndr, 8);
memcpy(v, ndr->data+ndr->offset, 8);
@@ -217,6 +226,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_ref_ptr(struct ndr_pull *ndr, uint32_t *v)
*/
_PUBLIC_ enum ndr_err_code ndr_pull_udlong(struct ndr_pull *ndr, int ndr_flags, uint64_t *v)
{
+ NDR_PULL_CHECK_FLAGS(ndr, ndr_flags);
NDR_PULL_ALIGN(ndr, 4);
NDR_PULL_NEED_BYTES(ndr, 8);
*v = NDR_IVAL(ndr, ndr->offset);
@@ -230,6 +240,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_udlong(struct ndr_pull *ndr, int ndr_flags,
*/
_PUBLIC_ enum ndr_err_code ndr_pull_udlongr(struct ndr_pull *ndr, int ndr_flags, uint64_t *v)
{
+ NDR_PULL_CHECK_FLAGS(ndr, ndr_flags);
NDR_PULL_ALIGN(ndr, 4);
NDR_PULL_NEED_BYTES(ndr, 8);
*v = ((uint64_t)NDR_IVAL(ndr, ndr->offset)) << 32;
@@ -264,6 +275,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_hyper(struct ndr_pull *ndr, int ndr_flags, u
_PUBLIC_ enum ndr_err_code ndr_pull_pointer(struct ndr_pull *ndr, int ndr_flags, void* *v)
{
uintptr_t h;
+ NDR_PULL_CHECK_FLAGS(ndr, ndr_flags);
NDR_PULL_ALIGN(ndr, sizeof(h));
NDR_PULL_NEED_BYTES(ndr, sizeof(h));
memcpy(&h, ndr->data+ndr->offset, sizeof(h));
@@ -278,6 +290,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_pointer(struct ndr_pull *ndr, int ndr_flags,
_PUBLIC_ enum ndr_err_code ndr_pull_NTSTATUS(struct ndr_pull *ndr, int ndr_flags, NTSTATUS *status)
{
uint32_t v;
+ NDR_PULL_CHECK_FLAGS(ndr, ndr_flags);
NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &v));
*status = NT_STATUS(v);
return NDR_ERR_SUCCESS;
@@ -302,6 +315,7 @@ _PUBLIC_ void ndr_print_NTSTATUS(struct ndr_print *ndr, const char *name, NTSTAT
_PUBLIC_ enum ndr_err_code ndr_pull_WERROR(struct ndr_pull *ndr, int ndr_flags, WERROR *status)
{
uint32_t v;
+ NDR_PULL_CHECK_FLAGS(ndr, ndr_flags);
NDR_CHECK(ndr_pull_uint32(ndr, NDR_SCALARS, &v));
*status = W_ERROR(v);
return NDR_ERR_SUCCESS;
@@ -414,6 +428,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_bytes(struct ndr_pull *ndr, uint8_t *data, u
*/
_PUBLIC_ enum ndr_err_code ndr_pull_array_uint8(struct ndr_pull *ndr, int ndr_flags, uint8_t *data, uint32_t n)
{
+ NDR_PULL_CHECK_FLAGS(ndr, ndr_flags);
if (!(ndr_flags & NDR_SCALARS)) {
return NDR_ERR_SUCCESS;
}
@@ -425,6 +440,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_array_uint8(struct ndr_pull *ndr, int ndr_fl
*/
_PUBLIC_ enum ndr_err_code ndr_push_int8(struct ndr_push *ndr, int ndr_flags, int8_t v)
{
+ NDR_PUSH_CHECK_FLAGS(ndr, ndr_flags);
NDR_PUSH_NEED_BYTES(ndr, 1);
SCVAL(ndr->data, ndr->offset, (uint8_t)v);
ndr->offset += 1;
@@ -436,6 +452,7 @@ _PUBLIC_ enum ndr_err_code ndr_push_int8(struct ndr_push *ndr, int ndr_flags, in
*/
_PUBLIC_ enum ndr_err_code ndr_push_uint8(struct ndr_push *ndr, int ndr_flags, uint8_t v)
{
+ NDR_PUSH_CHECK_FLAGS(ndr, ndr_flags);
NDR_PUSH_NEED_BYTES(ndr, 1);
SCVAL(ndr->data, ndr->offset, v);
ndr->offset += 1;
@@ -447,6 +464,7 @@ _PUBLIC_ enum ndr_err_code ndr_push_uint8(struct ndr_push *ndr, int ndr_flags, u
*/
_PUBLIC_ enum ndr_err_code ndr_push_int16(struct ndr_push *ndr, int ndr_flags, int16_t v)
{
+ NDR_PUSH_CHECK_FLAGS(ndr, ndr_flags);
NDR_PUSH_ALIGN(ndr, 2);
NDR_PUSH_NEED_BYTES(ndr, 2);
NDR_SSVAL(ndr, ndr->offset, (uint16_t)v);
@@ -459,6 +477,7 @@ _PUBLIC_ enum ndr_err_code ndr_push_int16(struct ndr_push *ndr, int ndr_flags, i
*/
_PUBLIC_ enum ndr_err_code ndr_push_uint16(struct ndr_push *ndr, int ndr_flags, uint16_t v)
{
+ NDR_PUSH_CHECK_FLAGS(ndr, ndr_flags);
NDR_PUSH_ALIGN(ndr, 2);
NDR_PUSH_NEED_BYTES(ndr, 2);
NDR_SSVAL(ndr, ndr->offset, v);
@@ -482,6 +501,7 @@ _PUBLIC_ enum ndr_err_code ndr_push_uint1632(struct ndr_push *ndr, int ndr_flags
*/
_PUBLIC_ enum ndr_err_code ndr_push_int32(struct ndr_push *ndr, int ndr_flags, int32_t v)
{
+ NDR_PUSH_CHECK_FLAGS(ndr, ndr_flags);
NDR_PUSH_ALIGN(ndr, 4);
NDR_PUSH_NEED_BYTES(ndr, 4);
NDR_SIVALS(ndr, ndr->offset, v);
@@ -494,6 +514,7 @@ _PUBLIC_ enum ndr_err_code ndr_push_int32(struct ndr_push *ndr, int ndr_flags, i
*/
_PUBLIC_ enum ndr_err_code ndr_push_uint32(struct ndr_push *ndr, int ndr_flags, uint32_t v)
{
+ NDR_PUSH_CHECK_FLAGS(ndr, ndr_flags);
NDR_PUSH_ALIGN(ndr, 4);
NDR_PUSH_NEED_BYTES(ndr, 4);
NDR_SIVAL(ndr, ndr->offset, v);
@@ -517,6 +538,7 @@ _PUBLIC_ enum ndr_err_code ndr_push_uint3264(struct ndr_push *ndr, int ndr_flags
*/
_PUBLIC_ enum ndr_err_code ndr_push_udlong(struct ndr_push *ndr, int ndr_flags, uint64_t v)
{
+ NDR_PUSH_CHECK_FLAGS(ndr, ndr_flags);
NDR_PUSH_ALIGN(ndr, 4);
NDR_PUSH_NEED_BYTES(ndr, 8);
NDR_SIVAL(ndr, ndr->offset, (v & 0xFFFFFFFF));
@@ -530,6 +552,7 @@ _PUBLIC_ enum ndr_err_code ndr_push_udlong(struct ndr_push *ndr, int ndr_flags,
*/
_PUBLIC_ enum ndr_err_code ndr_push_udlongr(struct ndr_push *ndr, int ndr_flags, uint64_t v)
{
+ NDR_PUSH_CHECK_FLAGS(ndr, ndr_flags);
NDR_PUSH_ALIGN(ndr, 4);
NDR_PUSH_NEED_BYTES(ndr, 8);
NDR_SIVAL(ndr, ndr->offset, (v>>32));
@@ -563,6 +586,7 @@ _PUBLIC_ enum ndr_err_code ndr_push_hyper(struct ndr_push *ndr, int ndr_flags, u
*/
_PUBLIC_ enum ndr_err_code ndr_push_double(struct ndr_push *ndr, int ndr_flags, double v)
{
+ NDR_PUSH_CHECK_FLAGS(ndr, ndr_flags);
NDR_PUSH_ALIGN(ndr, 8);
NDR_PUSH_NEED_BYTES(ndr, 8);
memcpy(ndr->data+ndr->offset, &v, 8);
@@ -576,6 +600,7 @@ _PUBLIC_ enum ndr_err_code ndr_push_double(struct ndr_push *ndr, int ndr_flags,
_PUBLIC_ enum ndr_err_code ndr_push_pointer(struct ndr_push *ndr, int ndr_flags, void* v)
{
uintptr_t h = (intptr_t)v;
+ NDR_PUSH_CHECK_FLAGS(ndr, ndr_flags);
NDR_PUSH_ALIGN(ndr, sizeof(h));
NDR_PUSH_NEED_BYTES(ndr, sizeof(h));
memcpy(ndr->data+ndr->offset, &h, sizeof(h));
@@ -686,6 +711,7 @@ _PUBLIC_ enum ndr_err_code ndr_push_zero(struct ndr_push *ndr, uint32_t n)
*/
_PUBLIC_ enum ndr_err_code ndr_push_array_uint8(struct ndr_push *ndr, int ndr_flags, const uint8_t *data, uint32_t n)
{
+ NDR_PUSH_CHECK_FLAGS(ndr, ndr_flags);
if (!(ndr_flags & NDR_SCALARS)) {
return NDR_ERR_SUCCESS;
}
@@ -738,6 +764,7 @@ _PUBLIC_ enum ndr_err_code ndr_push_ref_ptr(struct ndr_push *ndr)
*/
_PUBLIC_ enum ndr_err_code ndr_push_NTTIME(struct ndr_push *ndr, int ndr_flags, NTTIME t)
{
+ NDR_PUSH_CHECK_FLAGS(ndr, ndr_flags);
NDR_CHECK(ndr_push_udlong(ndr, ndr_flags, t));
return NDR_ERR_SUCCESS;
}
@@ -747,6 +774,7 @@ _PUBLIC_ enum ndr_err_code ndr_push_NTTIME(struct ndr_push *ndr, int ndr_flags,
*/
_PUBLIC_ enum ndr_err_code ndr_pull_NTTIME(struct ndr_pull *ndr, int ndr_flags, NTTIME *t)
{
+ NDR_PULL_CHECK_FLAGS(ndr, ndr_flags);
NDR_CHECK(ndr_pull_udlong(ndr, ndr_flags, t));
return NDR_ERR_SUCCESS;
}
@@ -756,6 +784,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_NTTIME(struct ndr_pull *ndr, int ndr_flags,
*/
_PUBLIC_ enum ndr_err_code ndr_push_NTTIME_1sec(struct ndr_push *ndr, int ndr_flags, NTTIME t)
{
+ NDR_PUSH_CHECK_FLAGS(ndr, ndr_flags);
t /= 10000000;
NDR_CHECK(ndr_push_hyper(ndr, ndr_flags, t));
return NDR_ERR_SUCCESS;
@@ -766,6 +795,7 @@ _PUBLIC_ enum ndr_err_code ndr_push_NTTIME_1sec(struct ndr_push *ndr, int ndr_fl
*/
_PUBLIC_ enum ndr_err_code ndr_pull_NTTIME_1sec(struct ndr_pull *ndr, int ndr_flags, NTTIME *t)
{
+ NDR_PULL_CHECK_FLAGS(ndr, ndr_flags);
NDR_CHECK(ndr_pull_hyper(ndr, ndr_flags, t));
(*t) *= 10000000;
return NDR_ERR_SUCCESS;
@@ -776,6 +806,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_NTTIME_1sec(struct ndr_pull *ndr, int ndr_fl
*/
_PUBLIC_ enum ndr_err_code ndr_pull_NTTIME_hyper(struct ndr_pull *ndr, int ndr_flags, NTTIME *t)
{
+ NDR_PULL_CHECK_FLAGS(ndr, ndr_flags);
NDR_CHECK(ndr_pull_hyper(ndr, ndr_flags, t));
return NDR_ERR_SUCCESS;
}
@@ -785,6 +816,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_NTTIME_hyper(struct ndr_pull *ndr, int ndr_f
*/
_PUBLIC_ enum ndr_err_code ndr_push_NTTIME_hyper(struct ndr_push *ndr, int ndr_flags, NTTIME t)
{
+ NDR_PUSH_CHECK_FLAGS(ndr, ndr_flags);
NDR_CHECK(ndr_push_hyper(ndr, ndr_flags, t));
return NDR_ERR_SUCCESS;
}
@@ -814,6 +846,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_time_t(struct ndr_pull *ndr, int ndr_flags,
*/
_PUBLIC_ enum ndr_err_code ndr_push_uid_t(struct ndr_push *ndr, int ndr_flags, uid_t u)
{
+ NDR_PUSH_CHECK_FLAGS(ndr, ndr_flags);
return ndr_push_hyper(ndr, NDR_SCALARS, (uint64_t)u);
}
@@ -839,6 +872,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_uid_t(struct ndr_pull *ndr, int ndr_flags, u
*/
_PUBLIC_ enum ndr_err_code ndr_push_gid_t(struct ndr_push *ndr, int ndr_flags, gid_t g)
{
+ NDR_PUSH_CHECK_FLAGS(ndr, ndr_flags);
return ndr_push_hyper(ndr, NDR_SCALARS, (uint64_t)g);
}