rpc_server: Move a type check in dcesrv_handle_lookup()
authorVolker Lendecke <vl@samba.org>
Mon, 20 Sep 2021 14:36:15 +0000 (16:36 +0200)
committerJeremy Allison <jra@samba.org>
Fri, 24 Sep 2021 23:55:32 +0000 (23:55 +0000)
This check is independent of whether we found a handle or not, we can
do it before walking the handle list.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
librpc/rpc/dcesrv_handles.c

index d50831bcf0af9bd6bed65178029b1bec8a5ef001..cb8b70300cc0ff52f89a15407beadf69b495e717 100644 (file)
@@ -104,15 +104,18 @@ struct dcesrv_handle *dcesrv_handle_lookup(struct dcesrv_call_state *call,
                return dcesrv_handle_create(call, handle_type);
        }
 
+       if (handle_type != DCESRV_HANDLE_ANY &&
+           p->handle_type != handle_type) {
+               DBG_WARNING("client gave us the wrong handle type "
+                           "(%"PRIu32" should be %"PRIu8")\n",
+                           p->handle_type,
+                           handle_type);
+               return NULL;
+       }
+
        for (h=context->conn->assoc_group->handles; h; h=h->next) {
                if (h->wire_handle.handle_type == p->handle_type &&
                    GUID_equal(&p->uuid, &h->wire_handle.uuid)) {
-                       if (handle_type != DCESRV_HANDLE_ANY &&
-                           p->handle_type != handle_type) {
-                               DEBUG(0,("client gave us the wrong handle type (%d should be %d)\n",
-                                        p->handle_type, handle_type));
-                               return NULL;
-                       }
                        if (!dom_sid_equal(&h->sid, sid)) {
                                struct dom_sid_buf buf1, buf2;
                                DBG_ERR("Attempt to use invalid sid %s - %s\n",