Robert Shearman : rpcrt4:
All of the parameters to TowerExplode are optional.
Alexandre Julliard
julliard at wine.codeweavers.com
Fri Jun 2 04:55:54 CDT 2006
Module: wine
Branch: refs/heads/master
Commit: efc974d1f57fe1da5fab3f55ac9eb80e233ff8ed
URL: http://source.winehq.org/git/?p=wine.git;a=commit;h=efc974d1f57fe1da5fab3f55ac9eb80e233ff8ed
Author: Robert Shearman <rob at codeweavers.com>
Date: Thu Jun 1 20:25:26 2006 +0100
rpcrt4: All of the parameters to TowerExplode are optional.
---
dlls/rpcrt4/rpc_epmap.c | 11 +++--
dlls/rpcrt4/rpc_transport.c | 104 ++++++++++++++++++++++++-------------------
dlls/rpcrt4/tests/rpc.c | 4 ++
3 files changed, 70 insertions(+), 49 deletions(-)
diff --git a/dlls/rpcrt4/rpc_epmap.c b/dlls/rpcrt4/rpc_epmap.c
index ffd3907..b3c3237 100644
--- a/dlls/rpcrt4/rpc_epmap.c
+++ b/dlls/rpcrt4/rpc_epmap.c
@@ -265,9 +265,12 @@ RPC_STATUS WINAPI TowerExplode(
const twr_uuid_floor_t *object_floor;
const twr_uuid_floor_t *syntax_floor;
- *protseq = NULL;
- *endpoint = NULL;
- *address = NULL;
+ if (protseq)
+ *protseq = NULL;
+ if (endpoint)
+ *endpoint = NULL;
+ if (address)
+ *address = NULL;
tower_size = tower->tower_length;
@@ -305,7 +308,7 @@ RPC_STATUS WINAPI TowerExplode(
return EPT_S_NOT_REGISTERED;
status = RpcTransport_ParseTopOfTower(p, tower_size, protseq, address, endpoint);
- if (status == RPC_S_OK)
+ if ((status == RPC_S_OK) && syntax && object)
{
syntax->SyntaxGUID = syntax_floor->uuid;
syntax->SyntaxVersion.MajorVersion = syntax_floor->major_version;
diff --git a/dlls/rpcrt4/rpc_transport.c b/dlls/rpcrt4/rpc_transport.c
index bcf7112..915f59a 100644
--- a/dlls/rpcrt4/rpc_transport.c
+++ b/dlls/rpcrt4/rpc_transport.c
@@ -308,9 +308,6 @@ static RPC_STATUS rpcrt4_ncacn_np_parse_
TRACE("(%p, %d, %p, %p)\n", tower_data, tower_size, networkaddr, endpoint);
- *networkaddr = NULL;
- *endpoint = NULL;
-
if (tower_size < sizeof(*smb_floor))
return EPT_S_NOT_REGISTERED;
@@ -321,11 +318,14 @@ static RPC_STATUS rpcrt4_ncacn_np_parse_
(smb_floor->protid != EPM_PROTOCOL_SMB) ||
(smb_floor->count_rhs > tower_size))
return EPT_S_NOT_REGISTERED;
-
- *endpoint = HeapAlloc(GetProcessHeap(), 0, smb_floor->count_rhs);
- if (!*endpoint)
- return RPC_S_OUT_OF_RESOURCES;
- memcpy(*endpoint, tower_data, smb_floor->count_rhs);
+
+ if (endpoint)
+ {
+ *endpoint = HeapAlloc(GetProcessHeap(), 0, smb_floor->count_rhs);
+ if (!*endpoint)
+ return RPC_S_OUT_OF_RESOURCES;
+ memcpy(*endpoint, tower_data, smb_floor->count_rhs);
+ }
tower_data += smb_floor->count_rhs;
tower_size -= smb_floor->count_rhs;
@@ -342,14 +342,20 @@ static RPC_STATUS rpcrt4_ncacn_np_parse_
(nb_floor->count_rhs > tower_size))
return EPT_S_NOT_REGISTERED;
- *networkaddr = HeapAlloc(GetProcessHeap(), 0, nb_floor->count_rhs);
- if (!*networkaddr)
+ if (networkaddr)
{
- HeapFree(GetProcessHeap(), 0, *endpoint);
- *endpoint = NULL;
- return RPC_S_OUT_OF_RESOURCES;
+ *networkaddr = HeapAlloc(GetProcessHeap(), 0, nb_floor->count_rhs);
+ if (!*networkaddr)
+ {
+ if (endpoint)
+ {
+ HeapFree(GetProcessHeap(), 0, *endpoint);
+ *endpoint = NULL;
+ }
+ return RPC_S_OUT_OF_RESOURCES;
+ }
+ memcpy(*networkaddr, tower_data, nb_floor->count_rhs);
}
- memcpy(*networkaddr, tower_data, nb_floor->count_rhs);
return RPC_S_OK;
}
@@ -406,11 +412,14 @@ static RPC_STATUS rpcrt4_ncalrpc_parse_t
(pipe_floor->protid != EPM_PROTOCOL_SMB) ||
(pipe_floor->count_rhs > tower_size))
return EPT_S_NOT_REGISTERED;
-
- *endpoint = HeapAlloc(GetProcessHeap(), 0, pipe_floor->count_rhs);
- if (!*endpoint)
- return RPC_S_OUT_OF_RESOURCES;
- memcpy(*endpoint, tower_data, pipe_floor->count_rhs);
+
+ if (endpoint)
+ {
+ *endpoint = HeapAlloc(GetProcessHeap(), 0, pipe_floor->count_rhs);
+ if (!*endpoint)
+ return RPC_S_OUT_OF_RESOURCES;
+ memcpy(*endpoint, tower_data, pipe_floor->count_rhs);
+ }
return RPC_S_OK;
}
@@ -620,9 +629,6 @@ static RPC_STATUS rpcrt4_ncacn_ip_tcp_pa
TRACE("(%p, %d, %p, %p)\n", tower_data, tower_size, networkaddr, endpoint);
- *networkaddr = NULL;
- *endpoint = NULL;
-
if (tower_size < sizeof(*tcp_floor))
return EPT_S_NOT_REGISTERED;
@@ -642,27 +648,39 @@ static RPC_STATUS rpcrt4_ncacn_ip_tcp_pa
(ipv4_floor->count_rhs != sizeof(ipv4_floor->ipv4addr)))
return EPT_S_NOT_REGISTERED;
- *endpoint = HeapAlloc(GetProcessHeap(), 0, 6);
- if (!*endpoint)
- return RPC_S_OUT_OF_RESOURCES;
- sprintf(*endpoint, "%u", ntohs(tcp_floor->port));
-
- *networkaddr = HeapAlloc(GetProcessHeap(), 0, INET_ADDRSTRLEN);
- if (!*networkaddr)
+ if (endpoint)
{
- HeapFree(GetProcessHeap(), 0, *endpoint);
- *endpoint = NULL;
- return RPC_S_OUT_OF_RESOURCES;
+ *endpoint = HeapAlloc(GetProcessHeap(), 0, 6);
+ if (!*endpoint)
+ return RPC_S_OUT_OF_RESOURCES;
+ sprintf(*endpoint, "%u", ntohs(tcp_floor->port));
}
- in_addr.s_addr = ipv4_floor->ipv4addr;
- if (!inet_ntop(AF_INET, &in_addr, *networkaddr, INET_ADDRSTRLEN))
+
+ if (networkaddr)
{
- ERR("inet_ntop: %s\n", strerror(errno));
- HeapFree(GetProcessHeap(), 0, *endpoint);
- HeapFree(GetProcessHeap(), 0, *networkaddr);
- *networkaddr = NULL;
- *endpoint = NULL;
- return EPT_S_NOT_REGISTERED;
+ *networkaddr = HeapAlloc(GetProcessHeap(), 0, INET_ADDRSTRLEN);
+ if (!*networkaddr)
+ {
+ if (endpoint)
+ {
+ HeapFree(GetProcessHeap(), 0, *endpoint);
+ *endpoint = NULL;
+ }
+ return RPC_S_OUT_OF_RESOURCES;
+ }
+ in_addr.s_addr = ipv4_floor->ipv4addr;
+ if (!inet_ntop(AF_INET, &in_addr, *networkaddr, INET_ADDRSTRLEN))
+ {
+ ERR("inet_ntop: %s\n", strerror(errno));
+ HeapFree(GetProcessHeap(), 0, *networkaddr);
+ *networkaddr = NULL;
+ if (endpoint)
+ {
+ HeapFree(GetProcessHeap(), 0, *endpoint);
+ *endpoint = NULL;
+ }
+ return EPT_S_NOT_REGISTERED;
+ }
}
return RPC_S_OK;
@@ -837,10 +855,6 @@ RPC_STATUS RpcTransport_ParseTopOfTower(
RPC_STATUS status;
int i;
- *protseq = NULL;
- *networkaddr = NULL;
- *endpoint = NULL;
-
if (tower_size < sizeof(*protocol_floor))
return EPT_S_NOT_REGISTERED;
@@ -869,7 +883,7 @@ RPC_STATUS RpcTransport_ParseTopOfTower(
status = protseq_ops->parse_top_of_tower(tower_data, tower_size, networkaddr, endpoint);
- if (status == RPC_S_OK)
+ if ((status == RPC_S_OK) && protseq)
{
*protseq = HeapAlloc(GetProcessHeap(), 0, strlen(protseq_ops->name) + 1);
strcpy(*protseq, protseq_ops->name);
diff --git a/dlls/rpcrt4/tests/rpc.c b/dlls/rpcrt4/tests/rpc.c
index 7f678bd..03dc792 100644
--- a/dlls/rpcrt4/tests/rpc.c
+++ b/dlls/rpcrt4/tests/rpc.c
@@ -265,6 +265,10 @@ static void test_towers(void)
I_RpcFree(protseq);
I_RpcFree(endpoint);
I_RpcFree(address);
+
+ ret = TowerExplode(tower, NULL, NULL, NULL, NULL, NULL);
+ ok(ret == RPC_S_OK, "TowerExplode failed with error %ld\n", ret);
+
I_RpcFree(tower);
}
More information about the wine-cvs
mailing list