]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
librpc/rpc: also get the 2nd half of the ndr_syntax_id from a floor
authorStefan Metzmacher <metze@samba.org>
Wed, 9 Aug 2023 17:39:21 +0000 (19:39 +0200)
committerAndrew Bartlett <abartlet@samba.org>
Tue, 17 Oct 2023 19:20:38 +0000 (19:20 +0000)
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
librpc/rpc/binding.c
librpc/rpc/rpc_common.h
source3/rpc_server/epmapper/srv_epmapper.c
source4/rpc_server/epmapper/rpc_epmapper.c
source4/torture/rpc/epmapper.c

index 132217dba5171635b02d744268917d425e4bb0b2..eaf3430c9d32207c08df757eb578e73ab5511c76 100644 (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;
index 36d54cd45bc61176c3271cc3b996ba6a930016be..b1c585447d275973ee3376c3d9dc970b26939d0d 100644 (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);
index 9031c7a6b0f5f56d10a6e879143793e6457686bf..cf6b268efdca408141b090a130a486a4be261735 100644 (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;
index d91fc8c0580fae8022b172d8e8b436ecc141894e..c104c79e4f82860fd4ec8a351f294d450814e056 100644 (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)) {
index 72b5165c6e8cc25f98b7ad92f98ae6acf373f2b4..d1202c25af49bc764d0364e85836db8020263be9 100644 (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",