From 686c0f094cdec400c41f6337748a73d40d0924dd Mon Sep 17 00:00:00 2001 From: Rob Shearman Date: Mon, 16 Jul 2007 15:00:59 +0100 Subject: [PATCH] rpcrt4: Even though FC_ENUM16 is an unsigned type, the highest allowable value that can be marshalled is SHRT_MAX, not USHRT_MAX. --- dlls/rpcrt4/ndr_marshall.c | 2 +- dlls/rpcrt4/tests/ndr_marshall.c | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/dlls/rpcrt4/ndr_marshall.c b/dlls/rpcrt4/ndr_marshall.c index d8395b80d44..7ff77e91848 100644 --- a/dlls/rpcrt4/ndr_marshall.c +++ b/dlls/rpcrt4/ndr_marshall.c @@ -5354,7 +5354,7 @@ static unsigned char *WINAPI NdrBaseTypeMarshall( break; case RPC_FC_ENUM16: /* only 16-bits on the wire, so do a sanity check */ - if (*(UINT *)pMemory > USHRT_MAX) + if (*(UINT *)pMemory > SHRT_MAX) RpcRaiseException(RPC_X_ENUM_VALUE_OUT_OF_RANGE); ALIGN_POINTER(pStubMsg->Buffer, sizeof(USHORT)); *(USHORT *)pStubMsg->Buffer = *(UINT *)pMemory; diff --git a/dlls/rpcrt4/tests/ndr_marshall.c b/dlls/rpcrt4/tests/ndr_marshall.c index ec129830179..f64c7668a91 100644 --- a/dlls/rpcrt4/tests/ndr_marshall.c +++ b/dlls/rpcrt4/tests/ndr_marshall.c @@ -418,8 +418,9 @@ static void test_simple_types(void) test_pointer_marshal(fmtstr_up_short, &s, 2, wiredata, 6, NULL, 0, "up_short"); test_pointer_marshal(fmtstr_up_ushort, &s, 2, wiredata, 6, NULL, 0, "up_ushort"); - i = s; + i = 0x7fff; *(void**)wiredata = &i; + *(unsigned short*)(wiredata + sizeof(void*)) = i; test_pointer_marshal(fmtstr_up_enum16, &i, 2, wiredata, 6, NULL, 0, "up_enum16"); l = 0xcafebabe;