Robert Shearman : rpcrt4: Fix embedded pointers in arrays by taking into account the iteration when calculating the appropriate memory and buffer pointers .

Alexandre Julliard julliard at wine.codeweavers.com
Mon May 15 09:42:49 CDT 2006


Module: wine
Branch: refs/heads/master
Commit: 788ce20deac20cb68ba1330de3dd95e92ab1c506
URL:    http://source.winehq.org/git/?p=wine.git;a=commit;h=788ce20deac20cb68ba1330de3dd95e92ab1c506

Author: Robert Shearman <rob at codeweavers.com>
Date:   Mon May 15 13:34:47 2006 +0100

rpcrt4: Fix embedded pointers in arrays by taking into account the iteration when calculating the appropriate memory and buffer pointers.

---

 dlls/rpcrt4/ndr_marshall.c |   45 ++++++++++++++++++++++++++------------------
 1 files changed, 27 insertions(+), 18 deletions(-)

diff --git a/dlls/rpcrt4/ndr_marshall.c b/dlls/rpcrt4/ndr_marshall.c
index 0fbf0f3..678c38f 100644
--- a/dlls/rpcrt4/ndr_marshall.c
+++ b/dlls/rpcrt4/ndr_marshall.c
@@ -981,6 +981,7 @@ unsigned char * WINAPI EmbeddedPointerMa
   unsigned char *Mark = pStubMsg->BufferMark;
   unsigned long Offset = pStubMsg->Offset;
   unsigned ofs, rep, count, stride, xofs;
+  unsigned i;
 
   TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
 
@@ -1016,17 +1017,17 @@ unsigned char * WINAPI EmbeddedPointerMa
       pFormat += 8;
       break;
     }
-    /* ofs doesn't seem to matter in this context */
-    while (rep) {
+    for (i = 0; i < rep; i++) {
       PFORMAT_STRING info = pFormat;
-      unsigned char *membase = pMemory + xofs;
+      unsigned char *membase = pMemory + (i * stride);
+      unsigned char *bufbase = Mark + (i * stride);
       unsigned u;
+      /* ofs doesn't seem to matter in this context */
       for (u=0; u<count; u++,info+=8) {
         unsigned char *memptr = membase + *(const SHORT*)&info[0];
-        unsigned char *bufptr = Mark + *(const SHORT*)&info[2];
+        unsigned char *bufptr = bufbase + *(const SHORT*)&info[2];
         PointerMarshall(pStubMsg, bufptr, *(unsigned char**)memptr, info+4);
       }
-      rep--;
     }
     pFormat += 8 * count;
   }
@@ -1047,6 +1048,7 @@ unsigned char * WINAPI EmbeddedPointerUn
   unsigned char *Mark = pStubMsg->BufferMark;
   unsigned long Offset = pStubMsg->Offset;
   unsigned ofs, rep, count, stride, xofs;
+  unsigned i;
 
   TRACE("(%p,%p,%p,%d)\n", pStubMsg, ppMemory, pFormat, fMustAlloc);
 
@@ -1054,6 +1056,7 @@ unsigned char * WINAPI EmbeddedPointerUn
   pFormat += 2;
 
   while (pFormat[0] != RPC_FC_END) {
+    TRACE("pFormat[0] = 0x%x\n", pFormat[0]);
     switch (pFormat[0]) {
     default:
       FIXME("unknown repeat type %d\n", pFormat[0]);
@@ -1083,16 +1086,17 @@ unsigned char * WINAPI EmbeddedPointerUn
       break;
     }
     /* ofs doesn't seem to matter in this context */
-    while (rep) {
+    for (i = 0; i < rep; i++) {
       PFORMAT_STRING info = pFormat;
-      unsigned char *membase = *ppMemory + xofs;
+      unsigned char *membase = *ppMemory + (i * stride);
+      unsigned char *bufbase = Mark + (i * stride);
       unsigned u;
       for (u=0; u<count; u++,info+=8) {
         unsigned char *memptr = membase + *(const SHORT*)&info[0];
-        unsigned char *bufptr = Mark + *(const SHORT*)&info[2];
+        unsigned char *bufptr = bufbase + *(const SHORT*)&info[2];
+        *(void **)memptr = NULL;
         PointerUnmarshall(pStubMsg, bufptr, (unsigned char**)memptr, info+4, fMustAlloc);
       }
-      rep--;
     }
     pFormat += 8 * count;
   }
@@ -1109,8 +1113,12 @@ void WINAPI EmbeddedPointerBufferSize(PM
 {
   unsigned long Offset = pStubMsg->Offset;
   unsigned ofs, rep, count, stride, xofs;
+  unsigned i;
 
   TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
+
+  if (pStubMsg->IgnoreEmbeddedPointers) return;
+
   if (*pFormat != RPC_FC_PP) return;
   pFormat += 2;
 
@@ -1144,15 +1152,14 @@ void WINAPI EmbeddedPointerBufferSize(PM
       break;
     }
     /* ofs doesn't seem to matter in this context */
-    while (rep) {
+    for (i = 0; i < rep; i++) {
       PFORMAT_STRING info = pFormat;
-      unsigned char *membase = pMemory + xofs;
+      unsigned char *membase = pMemory + (i * stride);
       unsigned u;
       for (u=0; u<count; u++,info+=8) {
         unsigned char *memptr = membase + *(const SHORT*)&info[0];
         PointerBufferSize(pStubMsg, *(unsigned char**)memptr, info+4);
       }
-      rep--;
     }
     pFormat += 8 * count;
   }
@@ -1167,8 +1174,10 @@ unsigned long WINAPI EmbeddedPointerMemo
   unsigned long Offset = pStubMsg->Offset;
   unsigned char *Mark = pStubMsg->BufferMark;
   unsigned ofs, rep, count, stride, xofs;
+  unsigned i;
 
   FIXME("(%p,%p): stub\n", pStubMsg, pFormat);
+
   if (*pFormat != RPC_FC_PP) return 0;
   pFormat += 2;
 
@@ -1202,14 +1211,14 @@ unsigned long WINAPI EmbeddedPointerMemo
       break;
     }
     /* ofs doesn't seem to matter in this context */
-    while (rep) {
+    for (i = 0; i < rep; i++) {
       PFORMAT_STRING info = pFormat;
+      unsigned char *bufbase = Mark + (i * stride);
       unsigned u;
       for (u=0; u<count; u++,info+=8) {
-        unsigned char *bufptr = Mark + *(const SHORT*)&info[2];
+        unsigned char *bufptr = bufbase + *(const SHORT*)&info[2];
         PointerMemorySize(pStubMsg, bufptr, info+4);
       }
-      rep--;
     }
     pFormat += 8 * count;
   }
@@ -1226,6 +1235,7 @@ void WINAPI EmbeddedPointerFree(PMIDL_ST
 {
   unsigned long Offset = pStubMsg->Offset;
   unsigned ofs, rep, count, stride, xofs;
+  unsigned i;
 
   TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
   if (*pFormat != RPC_FC_PP) return;
@@ -1261,15 +1271,14 @@ void WINAPI EmbeddedPointerFree(PMIDL_ST
       break;
     }
     /* ofs doesn't seem to matter in this context */
-    while (rep) {
+    for (i = 0; i < rep; i++) {
       PFORMAT_STRING info = pFormat;
-      unsigned char *membase = pMemory + xofs;
+      unsigned char *membase = pMemory + (i * stride);
       unsigned u;
       for (u=0; u<count; u++,info+=8) {
         unsigned char *memptr = membase + *(const SHORT*)&info[0];
         PointerFree(pStubMsg, *(unsigned char**)memptr, info+4);
       }
-      rep--;
     }
     pFormat += 8 * count;
   }




More information about the wine-cvs mailing list