1
0
mirror of https://github.com/samba-team/samba.git synced 2025-03-11 16:58:40 +03:00

librpc/rpc: also get the 2nd half of the ndr_syntax_id from a floor

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
This commit is contained in:
Stefan Metzmacher 2023-08-09 19:39:21 +02:00 committed by Andrew Bartlett
parent 1058382d04
commit 7a7a38b870
5 changed files with 37 additions and 13 deletions

View File

@ -134,7 +134,7 @@ const char *epm_floor_string(TALLOC_CTX *mem_ctx, struct epm_floor *epm_floor)
switch(epm_floor->lhs.protocol) {
case EPM_PROTOCOL_UUID:
status = dcerpc_floor_get_lhs_data(epm_floor, &syntax);
status = dcerpc_floor_get_uuid_full(epm_floor, &syntax);
if (NT_STATUS_IS_OK(status)) {
/* lhs is used: UUID */
struct GUID_txt_buf buf;
@ -894,14 +894,21 @@ _PUBLIC_ NTSTATUS dcerpc_binding_set_flags(struct dcerpc_binding *b,
return NT_STATUS_OK;
}
_PUBLIC_ NTSTATUS dcerpc_floor_get_lhs_data(const struct epm_floor *epm_floor,
struct ndr_syntax_id *syntax)
_PUBLIC_ NTSTATUS dcerpc_floor_get_uuid_full(const struct epm_floor *epm_floor,
struct ndr_syntax_id *syntax)
{
TALLOC_CTX *mem_ctx = talloc_init("floor_get_lhs_data");
struct ndr_pull *ndr;
enum ndr_err_code ndr_err;
uint16_t if_version=0;
*syntax = (struct ndr_syntax_id) { .if_version = 0, };
if (epm_floor->lhs.protocol != EPM_PROTOCOL_UUID) {
talloc_free(mem_ctx);
return NT_STATUS_INVALID_PARAMETER;
}
ndr = ndr_pull_init_blob(&epm_floor->lhs.lhs_data, mem_ctx);
if (ndr == NULL) {
talloc_free(mem_ctx);
@ -923,6 +930,23 @@ _PUBLIC_ NTSTATUS dcerpc_floor_get_lhs_data(const struct epm_floor *epm_floor,
syntax->if_version = if_version;
TALLOC_FREE(ndr);
ndr = ndr_pull_init_blob(&epm_floor->rhs.uuid.unknown, mem_ctx);
if (ndr == NULL) {
talloc_free(mem_ctx);
return NT_STATUS_NO_MEMORY;
}
ndr->flags |= LIBNDR_FLAG_NOALIGN;
ndr_err = ndr_pull_uint16(ndr, NDR_SCALARS, &if_version);
if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
talloc_free(mem_ctx);
return ndr_map_error2ntstatus(ndr_err);
}
syntax->if_version |= (((uint32_t)if_version) << 16) & 0xffff0000;
talloc_free(mem_ctx);
return NT_STATUS_OK;
@ -1261,7 +1285,7 @@ _PUBLIC_ NTSTATUS dcerpc_binding_from_tower(TALLOC_CTX *mem_ctx,
}
/* Set abstract syntax */
status = dcerpc_floor_get_lhs_data(&tower->floors[0], &abstract_syntax);
status = dcerpc_floor_get_uuid_full(&tower->floors[0], &abstract_syntax);
if (!NT_STATUS_IS_OK(status)) {
talloc_free(b);
return status;

View File

@ -160,7 +160,7 @@ uint32_t dcerpc_binding_get_flags(const struct dcerpc_binding *b);
NTSTATUS dcerpc_binding_set_flags(struct dcerpc_binding *b,
uint32_t additional,
uint32_t clear);
NTSTATUS dcerpc_floor_get_lhs_data(const struct epm_floor *epm_floor, struct ndr_syntax_id *syntax);
NTSTATUS dcerpc_floor_get_uuid_full(const struct epm_floor *epm_floor, struct ndr_syntax_id *syntax);
const char *derpc_transport_string_by_transport(enum dcerpc_transport_t t);
enum dcerpc_transport_t dcerpc_transport_by_name(const char *name);
enum dcerpc_transport_t dcerpc_transport_by_tower(const struct epm_tower *tower);

View File

@ -795,9 +795,9 @@ error_status_t _epm_Map(struct pipes_struct *p,
floors = r->in.map_tower->tower.floors;
/* We accept NDR as the transfer syntax */
status = dcerpc_floor_get_lhs_data(&floors[1], &ifid);
status = dcerpc_floor_get_uuid_full(&floors[1], &ifid);
if (!NT_STATUS_IS_OK(status)) {
DBG_DEBUG("dcerpc_floor_get_lhs_data() failed: %s\n",
DBG_DEBUG("dcerpc_floor_get_uuid_full() failed: %s\n",
nt_errstr(status));
rc = EPMAPPER_STATUS_NO_MORE_ENTRIES;
goto done;
@ -832,9 +832,9 @@ error_status_t _epm_Map(struct pipes_struct *p,
DEBUG(7, ("_epm_Map: No entry_handle found, creating it.\n"));
status = dcerpc_floor_get_lhs_data(&floors[0], &ifid);
status = dcerpc_floor_get_uuid_full(&floors[0], &ifid);
if (!NT_STATUS_IS_OK(status)) {
DBG_DEBUG("dcerpc_floor_get_lhs_data() failed: %s\n",
DBG_DEBUG("dcerpc_floor_get_uuid_full() failed: %s\n",
nt_errstr(status));
rc = EPMAPPER_STATUS_NO_MORE_ENTRIES;
goto done;

View File

@ -218,7 +218,7 @@ static error_status_t dcesrv_epm_Map(struct dcesrv_call_state *dce_call, TALLOC_
floors = r->in.map_tower->tower.floors;
dcerpc_floor_get_lhs_data(&r->in.map_tower->tower.floors[1], &ndr_syntax);
dcerpc_floor_get_uuid_full(&r->in.map_tower->tower.floors[1], &ndr_syntax);
if (floors[1].lhs.protocol != EPM_PROTOCOL_UUID ||
!ndr_syntax_id_equal(&ndr_syntax, &ndr_transfer_syntax_ndr)) {

View File

@ -198,7 +198,7 @@ static bool test_Map_tcpip(struct torture_context *tctx,
t = r.out.towers[0].twr->tower;
/* Check if we got the correct RPC interface identifier */
dcerpc_floor_get_lhs_data(&t.floors[0], &syntax);
dcerpc_floor_get_uuid_full(&t.floors[0], &syntax);
torture_assert(tctx, ndr_syntax_id_equal(&syntax, &map_syntax),
"epm_Map_tcpip failed: Interface identifier mismatch");
@ -206,7 +206,7 @@ static bool test_Map_tcpip(struct torture_context *tctx,
"epm_Map_tcpip response for '%s':\n",
ndr_interface_name(&syntax.uuid, syntax.if_version));
dcerpc_floor_get_lhs_data(&t.floors[1], &syntax);
dcerpc_floor_get_uuid_full(&t.floors[1], &syntax);
torture_assert(tctx, ndr_syntax_id_equal(&syntax, &ndr_transfer_syntax_ndr),
"epm_Map_tcpip failed: floor 2 is not NDR encoded");
@ -285,7 +285,7 @@ static bool test_Map_display(struct dcerpc_binding_handle *b,
r.in.max_towers = 10;
r.out.num_towers = &num_towers;
dcerpc_floor_get_lhs_data(&twr->tower.floors[0], &syntax);
dcerpc_floor_get_uuid_full(&twr->tower.floors[0], &syntax);
torture_comment(tctx,
"epm_Map results for '%s':\n",