Commit 37dd4415 authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

rpcrt4: Fix argument check in MesEncodeFixedBufferHandleCreate().

parent 0810db96
...@@ -42,6 +42,7 @@ static inline void init_MIDL_ES_MESSAGE(MIDL_ES_MESSAGE *pEsMsg) ...@@ -42,6 +42,7 @@ static inline void init_MIDL_ES_MESSAGE(MIDL_ES_MESSAGE *pEsMsg)
/* even if we are unmarshalling, as we don't want pointers to be pointed /* even if we are unmarshalling, as we don't want pointers to be pointed
* to buffer memory */ * to buffer memory */
pEsMsg->StubMsg.IsClient = TRUE; pEsMsg->StubMsg.IsClient = TRUE;
pEsMsg->MesVersion = 1;
} }
/*********************************************************************** /***********************************************************************
...@@ -142,6 +143,17 @@ RPC_STATUS RPC_ENTRY MesEncodeFixedBufferHandleCreate( ...@@ -142,6 +143,17 @@ RPC_STATUS RPC_ENTRY MesEncodeFixedBufferHandleCreate(
TRACE("(%p, %d, %p, %p)\n", Buffer, BufferSize, pEncodedSize, pHandle); TRACE("(%p, %d, %p, %p)\n", Buffer, BufferSize, pEncodedSize, pHandle);
if (!Buffer)
return RPC_S_INVALID_ARG;
if (((ULONG_PTR)Buffer % 8) != 0)
return RPC_X_INVALID_BUFFER;
if (!pEncodedSize)
return RPC_S_INVALID_ARG;
/* FIXME: check BufferSize too */
pEsMsg = HeapAlloc(GetProcessHeap(), 0, sizeof(*pEsMsg)); pEsMsg = HeapAlloc(GetProcessHeap(), 0, sizeof(*pEsMsg));
if (!pEsMsg) if (!pEsMsg)
return RPC_S_OUT_OF_MEMORY; return RPC_S_OUT_OF_MEMORY;
......
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
#include "rpc.h" #include "rpc.h"
#include "rpcdce.h" #include "rpcdce.h"
#include "rpcproxy.h" #include "rpcproxy.h"
#include "midles.h"
static int my_alloc_called; static int my_alloc_called;
static int my_free_called; static int my_free_called;
...@@ -2405,6 +2405,42 @@ static void test_NdrGetUserMarshalInfo(void) ...@@ -2405,6 +2405,42 @@ static void test_NdrGetUserMarshalInfo(void)
"NdrGetUserMarshalInfo should have failed with RPC_S_INVALID_ARG instead of %d\n", status); "NdrGetUserMarshalInfo should have failed with RPC_S_INVALID_ARG instead of %d\n", status);
} }
static void test_MesEncodeFixedBufferHandleCreate(void)
{
ULONG encoded_size;
RPC_STATUS status;
handle_t handle;
char *buffer;
status = MesEncodeFixedBufferHandleCreate(NULL, 0, NULL, NULL);
ok(status == RPC_S_INVALID_ARG, "got %d\n", status);
status = MesEncodeFixedBufferHandleCreate(NULL, 0, NULL, &handle);
ok(status == RPC_S_INVALID_ARG, "got %d\n", status);
status = MesEncodeFixedBufferHandleCreate((char*)0xdeadbeef, 0, NULL, &handle);
ok(status == RPC_X_INVALID_BUFFER, "got %d\n", status);
buffer = (void*)((0xdeadbeef + 7) & ~7);
status = MesEncodeFixedBufferHandleCreate(buffer, 0, NULL, &handle);
ok(status == RPC_S_INVALID_ARG, "got %d\n", status);
status = MesEncodeFixedBufferHandleCreate(buffer, 0, &encoded_size, &handle);
todo_wine
ok(status == RPC_S_INVALID_ARG, "got %d\n", status);
if (status == RPC_S_OK)
MesHandleFree(handle);
status = MesEncodeFixedBufferHandleCreate(buffer, 32, NULL, &handle);
ok(status == RPC_S_INVALID_ARG, "got %d\n", status);
status = MesEncodeFixedBufferHandleCreate(buffer, 32, &encoded_size, &handle);
ok(status == RPC_S_OK, "got %d\n", status);
status = MesHandleFree(handle);
ok(status == RPC_S_OK, "got %d\n", status);
}
START_TEST( ndr_marshall ) START_TEST( ndr_marshall )
{ {
determine_pointer_marshalling_style(); determine_pointer_marshalling_style();
...@@ -2425,4 +2461,5 @@ START_TEST( ndr_marshall ) ...@@ -2425,4 +2461,5 @@ START_TEST( ndr_marshall )
test_ndr_buffer(); test_ndr_buffer();
test_NdrMapCommAndFaultStatus(); test_NdrMapCommAndFaultStatus();
test_NdrGetUserMarshalInfo(); test_NdrGetUserMarshalInfo();
test_MesEncodeFixedBufferHandleCreate();
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment