Robert Shearman : rpcrt4: Correctly align the buffer before reading/
writing structure data.
Alexandre Julliard
julliard at wine.codeweavers.com
Wed May 10 12:56:51 CDT 2006
Module: wine
Branch: refs/heads/master
Commit: 95d79e2c581d9ea734290c224c1cef1302b6358a
URL: http://source.winehq.org/git/?p=wine.git;a=commit;h=95d79e2c581d9ea734290c224c1cef1302b6358a
Author: Robert Shearman <rob at codeweavers.com>
Date: Wed May 10 13:12:30 2006 +0100
rpcrt4: Correctly align the buffer before reading/writing structure data.
---
dlls/rpcrt4/ndr_marshall.c | 19 +++++++++++++++++++
1 files changed, 19 insertions(+), 0 deletions(-)
diff --git a/dlls/rpcrt4/ndr_marshall.c b/dlls/rpcrt4/ndr_marshall.c
index ac38bce..567ae0b 100644
--- a/dlls/rpcrt4/ndr_marshall.c
+++ b/dlls/rpcrt4/ndr_marshall.c
@@ -1321,6 +1321,8 @@ unsigned char * WINAPI NdrSimpleStructMa
unsigned size = *(const WORD*)(pFormat+2);
TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
+ ALIGN_POINTER(pStubMsg->Buffer, pFormat[1] + 1);
+
memcpy(pStubMsg->Buffer, pMemory, size);
pStubMsg->BufferMark = pStubMsg->Buffer;
pStubMsg->Buffer += size;
@@ -1344,6 +1346,8 @@ unsigned char * WINAPI NdrSimpleStructUn
unsigned size = *(const WORD*)(pFormat+2);
TRACE("(%p,%p,%p,%d)\n", pStubMsg, ppMemory, pFormat, fMustAlloc);
+ ALIGN_POINTER(pStubMsg->Buffer, pFormat[1] + 1);
+
if (fMustAlloc) {
*ppMemory = NdrAllocate(pStubMsg, size);
memcpy(*ppMemory, pStubMsg->Buffer, size);
@@ -1396,6 +1400,9 @@ void WINAPI NdrSimpleStructBufferSize(PM
{
unsigned size = *(const WORD*)(pFormat+2);
TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
+
+ ALIGN_LENGTH(pStubMsg->BufferLength, pFormat[1] + 1);
+
pStubMsg->BufferLength += size;
if (pFormat[0] != RPC_FC_STRUCT)
EmbeddedPointerBufferSize(pStubMsg, pMemory, pFormat+4);
@@ -1751,6 +1758,8 @@ unsigned char * WINAPI NdrComplexStructM
TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
+ ALIGN_POINTER(pStubMsg->Buffer, pFormat[1] + 1);
+
pFormat += 4;
if (*(const WORD*)pFormat) conf_array = pFormat + *(const WORD*)pFormat;
pFormat += 2;
@@ -1786,6 +1795,8 @@ unsigned char * WINAPI NdrComplexStructU
TRACE("(%p,%p,%p,%d)\n", pStubMsg, ppMemory, pFormat, fMustAlloc);
+ ALIGN_POINTER(pStubMsg->Buffer, pFormat[1] + 1);
+
if (fMustAlloc || !*ppMemory)
{
*ppMemory = NdrAllocate(pStubMsg, size);
@@ -1819,6 +1830,8 @@ void WINAPI NdrComplexStructBufferSize(P
TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
+ ALIGN_LENGTH(pStubMsg->BufferLength, pFormat[1] + 1);
+
pFormat += 4;
if (*(const WORD*)pFormat) conf_array = pFormat + *(const WORD*)pFormat;
pFormat += 2;
@@ -2479,6 +2492,8 @@ unsigned char * WINAPI NdrConformantStr
return NULL;
}
+ ALIGN_POINTER(pStubMsg->Buffer, pCStructFormat->alignment + 1);
+
TRACE("memory_size = %d\n", pCStructFormat->memory_size);
/* copy constant sized part of struct */
@@ -2516,6 +2531,8 @@ unsigned char * WINAPI NdrConformantStr
return NULL;
}
+ ALIGN_POINTER(pStubMsg->Buffer, pCStructFormat->alignment + 1);
+
TRACE("memory_size = %d\n", pCStructFormat->memory_size);
/* work out how much memory to allocate if we need to do so */
@@ -2571,6 +2588,8 @@ void WINAPI NdrConformantStructBufferSiz
return;
}
+ ALIGN_LENGTH(pStubMsg->BufferLength, pCStructFormat->alignment + 1);
+
TRACE("memory_size = %d\n", pCStructFormat->memory_size);
/* add constant sized part of struct to buffer size */
More information about the wine-cvs
mailing list