rpcrt4: Correctly align the buffer before reading/writing structure data.
This commit is contained in:
parent
5616c4150c
commit
95d79e2c58
|
@ -1321,6 +1321,8 @@ unsigned char * WINAPI NdrSimpleStructMarshall(PMIDL_STUB_MESSAGE pStubMsg,
|
||||||
unsigned size = *(const WORD*)(pFormat+2);
|
unsigned size = *(const WORD*)(pFormat+2);
|
||||||
TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
|
TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
|
||||||
|
|
||||||
|
ALIGN_POINTER(pStubMsg->Buffer, pFormat[1] + 1);
|
||||||
|
|
||||||
memcpy(pStubMsg->Buffer, pMemory, size);
|
memcpy(pStubMsg->Buffer, pMemory, size);
|
||||||
pStubMsg->BufferMark = pStubMsg->Buffer;
|
pStubMsg->BufferMark = pStubMsg->Buffer;
|
||||||
pStubMsg->Buffer += size;
|
pStubMsg->Buffer += size;
|
||||||
|
@ -1344,6 +1346,8 @@ unsigned char * WINAPI NdrSimpleStructUnmarshall(PMIDL_STUB_MESSAGE pStubMsg,
|
||||||
unsigned size = *(const WORD*)(pFormat+2);
|
unsigned size = *(const WORD*)(pFormat+2);
|
||||||
TRACE("(%p,%p,%p,%d)\n", pStubMsg, ppMemory, pFormat, fMustAlloc);
|
TRACE("(%p,%p,%p,%d)\n", pStubMsg, ppMemory, pFormat, fMustAlloc);
|
||||||
|
|
||||||
|
ALIGN_POINTER(pStubMsg->Buffer, pFormat[1] + 1);
|
||||||
|
|
||||||
if (fMustAlloc) {
|
if (fMustAlloc) {
|
||||||
*ppMemory = NdrAllocate(pStubMsg, size);
|
*ppMemory = NdrAllocate(pStubMsg, size);
|
||||||
memcpy(*ppMemory, pStubMsg->Buffer, size);
|
memcpy(*ppMemory, pStubMsg->Buffer, size);
|
||||||
|
@ -1396,6 +1400,9 @@ void WINAPI NdrSimpleStructBufferSize(PMIDL_STUB_MESSAGE pStubMsg,
|
||||||
{
|
{
|
||||||
unsigned size = *(const WORD*)(pFormat+2);
|
unsigned size = *(const WORD*)(pFormat+2);
|
||||||
TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
|
TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
|
||||||
|
|
||||||
|
ALIGN_LENGTH(pStubMsg->BufferLength, pFormat[1] + 1);
|
||||||
|
|
||||||
pStubMsg->BufferLength += size;
|
pStubMsg->BufferLength += size;
|
||||||
if (pFormat[0] != RPC_FC_STRUCT)
|
if (pFormat[0] != RPC_FC_STRUCT)
|
||||||
EmbeddedPointerBufferSize(pStubMsg, pMemory, pFormat+4);
|
EmbeddedPointerBufferSize(pStubMsg, pMemory, pFormat+4);
|
||||||
|
@ -1751,6 +1758,8 @@ unsigned char * WINAPI NdrComplexStructMarshall(PMIDL_STUB_MESSAGE pStubMsg,
|
||||||
|
|
||||||
TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
|
TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
|
||||||
|
|
||||||
|
ALIGN_POINTER(pStubMsg->Buffer, pFormat[1] + 1);
|
||||||
|
|
||||||
pFormat += 4;
|
pFormat += 4;
|
||||||
if (*(const WORD*)pFormat) conf_array = pFormat + *(const WORD*)pFormat;
|
if (*(const WORD*)pFormat) conf_array = pFormat + *(const WORD*)pFormat;
|
||||||
pFormat += 2;
|
pFormat += 2;
|
||||||
|
@ -1786,6 +1795,8 @@ unsigned char * WINAPI NdrComplexStructUnmarshall(PMIDL_STUB_MESSAGE pStubMsg,
|
||||||
|
|
||||||
TRACE("(%p,%p,%p,%d)\n", pStubMsg, ppMemory, pFormat, fMustAlloc);
|
TRACE("(%p,%p,%p,%d)\n", pStubMsg, ppMemory, pFormat, fMustAlloc);
|
||||||
|
|
||||||
|
ALIGN_POINTER(pStubMsg->Buffer, pFormat[1] + 1);
|
||||||
|
|
||||||
if (fMustAlloc || !*ppMemory)
|
if (fMustAlloc || !*ppMemory)
|
||||||
{
|
{
|
||||||
*ppMemory = NdrAllocate(pStubMsg, size);
|
*ppMemory = NdrAllocate(pStubMsg, size);
|
||||||
|
@ -1819,6 +1830,8 @@ void WINAPI NdrComplexStructBufferSize(PMIDL_STUB_MESSAGE pStubMsg,
|
||||||
|
|
||||||
TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
|
TRACE("(%p,%p,%p)\n", pStubMsg, pMemory, pFormat);
|
||||||
|
|
||||||
|
ALIGN_LENGTH(pStubMsg->BufferLength, pFormat[1] + 1);
|
||||||
|
|
||||||
pFormat += 4;
|
pFormat += 4;
|
||||||
if (*(const WORD*)pFormat) conf_array = pFormat + *(const WORD*)pFormat;
|
if (*(const WORD*)pFormat) conf_array = pFormat + *(const WORD*)pFormat;
|
||||||
pFormat += 2;
|
pFormat += 2;
|
||||||
|
@ -2479,6 +2492,8 @@ unsigned char * WINAPI NdrConformantStructMarshall(PMIDL_STUB_MESSAGE pStubMsg,
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ALIGN_POINTER(pStubMsg->Buffer, pCStructFormat->alignment + 1);
|
||||||
|
|
||||||
TRACE("memory_size = %d\n", pCStructFormat->memory_size);
|
TRACE("memory_size = %d\n", pCStructFormat->memory_size);
|
||||||
|
|
||||||
/* copy constant sized part of struct */
|
/* copy constant sized part of struct */
|
||||||
|
@ -2516,6 +2531,8 @@ unsigned char * WINAPI NdrConformantStructUnmarshall(PMIDL_STUB_MESSAGE pStubMs
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ALIGN_POINTER(pStubMsg->Buffer, pCStructFormat->alignment + 1);
|
||||||
|
|
||||||
TRACE("memory_size = %d\n", pCStructFormat->memory_size);
|
TRACE("memory_size = %d\n", pCStructFormat->memory_size);
|
||||||
|
|
||||||
/* work out how much memory to allocate if we need to do so */
|
/* work out how much memory to allocate if we need to do so */
|
||||||
|
@ -2571,6 +2588,8 @@ void WINAPI NdrConformantStructBufferSize(PMIDL_STUB_MESSAGE pStubMsg,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ALIGN_LENGTH(pStubMsg->BufferLength, pCStructFormat->alignment + 1);
|
||||||
|
|
||||||
TRACE("memory_size = %d\n", pCStructFormat->memory_size);
|
TRACE("memory_size = %d\n", pCStructFormat->memory_size);
|
||||||
|
|
||||||
/* add constant sized part of struct to buffer size */
|
/* add constant sized part of struct to buffer size */
|
||||||
|
|
Loading…
Reference in New Issue