Rob Shearman : rpcrt4: Even though FC_ENUM16 is an unsigned type, the highest allowable value that can be marshalled is SHRT_MAX, not USHRT_MAX.

Alexandre Julliard julliard at wine.codeweavers.com
Mon Jul 16 16:27:16 CDT 2007


Module: wine
Branch: master
Commit: 686c0f094cdec400c41f6337748a73d40d0924dd
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=686c0f094cdec400c41f6337748a73d40d0924dd

Author: Rob Shearman <rob at codeweavers.com>
Date:   Mon Jul 16 15:00:59 2007 +0100

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 d8395b8..7ff77e9 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 ec12983..f64c766 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;




More information about the wine-cvs mailing list