rpcrt4: Check for null endpoint in RpcServerUseProtseqEpExW

Rob Shearman robertshearman at gmail.com
Fri Feb 6 08:18:24 CST 2009


2009/2/6 Nikolay Sivov <bunglehead at gmail.com>:
> Rob Shearman wrote:
>> 2009/2/5 Nikolay Sivov <bunglehead at gmail.com>:
>>
>>> Changelog:
>>>    - Check for null endpoint in RpcServerUseProtseqEpExW.
>>>      Installed IE8 RC1 crashes on this call, parameter set is specified in
>>>      test case.
>>>
>>> >From 89f889b2c7a754302b599884577b4eba22b3d235 Mon Sep 17 00:00:00 2001
>>> From: Nikolay Sivov <bunglehead at gmail.com>
>>> Date: Thu, 5 Feb 2009 22:03:48 +0300
>>> Subject: Check for null endpoint in RpcServerUseProtseqEpExW
>>>
>>> ---
>>>  dlls/rpcrt4/rpc_server.c |    6 ++++--
>>>  dlls/rpcrt4/tests/rpc.c  |   15 +++++++++++++++
>>>  2 files changed, 19 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/dlls/rpcrt4/rpc_server.c b/dlls/rpcrt4/rpc_server.c
>>> index b6e058a..e9bed42 100644
>>> --- a/dlls/rpcrt4/rpc_server.c
>>> +++ b/dlls/rpcrt4/rpc_server.c
>>> @@ -775,8 +775,10 @@ RPC_STATUS WINAPI RpcServerUseProtseqEpExW( RPC_WSTR Protseq, UINT MaxCalls, RPC
>>>     return status;
>>>
>>>   EndpointA = RPCRT4_strdupWtoA(Endpoint);
>>> -  status = RPCRT4_use_protseq(ps, EndpointA);
>>> -  RPCRT4_strfree(EndpointA);
>>> +  if (EndpointA) {
>>> +      status = RPCRT4_use_protseq(ps, EndpointA);
>>> +      RPCRT4_strfree(EndpointA);
>>> +  }
>>>
>>
>> This isn't correct, I'm afraid. The protseq open function should
>> generate an endpoint name to use. For example, the ncacn_ip_tcp code
>> should select a random available TCP port.
>>
>>
>>>   return status;
>>>  }
>>>
>>> diff --git a/dlls/rpcrt4/tests/rpc.c b/dlls/rpcrt4/tests/rpc.c
>>> index bf538e4..b815acc 100644
>>> --- a/dlls/rpcrt4/tests/rpc.c
>>> +++ b/dlls/rpcrt4/tests/rpc.c
>>> @@ -830,6 +830,20 @@ static void test_UuidCreate(void)
>>>     }
>>>  }
>>>
>>> +static void test_RpcServerUseProtseqEpEx(void)
>>> +{
>>> +    RPC_STATUS status;
>>> +    RPC_POLICY policy;
>>> +    static WCHAR protW[] = {'n','c','a','l','r','p','c',0};
>>> +
>>> +    policy.Length        = sizeof( policy );
>>> +    policy.EndpointFlags = 0;
>>> +    policy.NICFlags      = 0;
>>> +
>>> +    status = RpcServerUseProtseqEpExW(protW, 10, NULL, NULL, &policy);
>>> +    ok(status == RPC_S_OK, "Expected RPC_S_OK, got %d\n", status);
>>> +}
>>>
>>
>> This is a good start, but you should also test the bindings created as
>> a result of doing this and then you will probably discover that the
>> fix to RpcServerUseProtseqEpExW isn't quite correct.
>>
>>
>>
>>>  START_TEST( rpc )
>>>  {
>>>     static unsigned char ncacn_np[] = "ncacn_np";
>>> @@ -849,4 +863,5 @@ START_TEST( rpc )
>>>     test_endpoint_mapper(ncalrpc, NULL, lrpc_endpoint);
>>>     test_RpcStringBindingFromBinding();
>>>     test_UuidCreate();
>>> +    test_RpcServerUseProtseqEpEx();
>>>  }
>>>
>>
>>
> Ok, I'll try to find out.
> Rob, could you suggest a good documentation source on RPC? I'm not
> experienced in it.

Sure, although this particular aspect isn't well documented. I did
find a couple of references, but you have to fill in the blanks to get
to the conclusion that RpcServerUseProtseqEpEx with a NULL endpoint
should generate an otherwise unused endpoint string:
http://www.opengroup.org/onlinepubs/9629399/chap2.htm#tagcjh_05_02_03
http://msdn.microsoft.com/en-us/library/aa378452(VS.85).aspx - "The
endpoint name is generated by the RPC run time or the operating
system."

The following may also be useful in future RPC issues, but not in this case:
http://msdn.microsoft.com/en-us/library/cc243560(PROT.10).aspx

-- 
Rob Shearman



More information about the wine-devel mailing list