rpcrt4: Allow NULL networkaddr and endpoint in rpcrt4_np_get_top_of_tower.

Add tests for this.
This commit is contained in:
Rob Shearman 2008-01-15 12:09:52 +00:00 committed by Alexandre Julliard
parent 7b40fd645d
commit 1a3d7c77a5
2 changed files with 20 additions and 4 deletions

View File

@ -422,8 +422,8 @@ static size_t rpcrt4_ncacn_np_get_top_of_tower(unsigned char *tower_data,
TRACE("(%p, %s, %s)\n", tower_data, networkaddr, endpoint);
networkaddr_size = strlen(networkaddr) + 1;
endpoint_size = strlen(endpoint) + 1;
networkaddr_size = networkaddr ? strlen(networkaddr) + 1 : 1;
endpoint_size = endpoint ? strlen(endpoint) + 1 : 1;
size = sizeof(*smb_floor) + endpoint_size + sizeof(*nb_floor) + networkaddr_size;
if (!tower_data)
@ -437,7 +437,10 @@ static size_t rpcrt4_ncacn_np_get_top_of_tower(unsigned char *tower_data,
smb_floor->protid = EPM_PROTOCOL_SMB;
smb_floor->count_rhs = endpoint_size;
memcpy(tower_data, endpoint, endpoint_size);
if (endpoint)
memcpy(tower_data, endpoint, endpoint_size);
else
tower_data[0] = 0;
tower_data += endpoint_size;
nb_floor = (twr_empty_floor_t *)tower_data;
@ -448,7 +451,10 @@ static size_t rpcrt4_ncacn_np_get_top_of_tower(unsigned char *tower_data,
nb_floor->protid = EPM_PROTOCOL_NETBIOS;
nb_floor->count_rhs = networkaddr_size;
memcpy(tower_data, networkaddr, networkaddr_size);
if (networkaddr)
memcpy(tower_data, networkaddr, networkaddr_size);
else
tower_data[0] = 0;
tower_data += networkaddr_size;
return size;

View File

@ -374,6 +374,16 @@ static void test_towers(void)
I_RpcFree(address);
I_RpcFree(tower);
/* test the behaviour for np with no address */
ret = TowerConstruct(&mapi_if_id, &ndr_syntax, "ncacn_np", "\\pipe\\test", NULL, &tower);
ok(ret == RPC_S_OK, "TowerConstruct failed with error %ld\n", ret);
ret = TowerExplode(tower, NULL, NULL, NULL, NULL, &address);
ok(ret == RPC_S_OK, "TowerExplode failed with error %ld\n", ret);
ok(!strcmp(address, ""), "address was \"%s\" instead of \"\"\n", address);
I_RpcFree(address);
I_RpcFree(tower);
}
static void test_I_RpcMapWin32Status(void)