From: Volker Lendecke Date: Mon, 20 Sep 2021 14:36:15 +0000 (+0200) Subject: rpc_server: Move a type check in dcesrv_handle_lookup() X-Git-Tag: ldb-2.5.0~558 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=acaa89aac9d0ae6b655ea606aaa576d261e92fac;p=thirdparty%2Fsamba.git rpc_server: Move a type check in dcesrv_handle_lookup() 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 Reviewed-by: Jeremy Allison --- diff --git a/librpc/rpc/dcesrv_handles.c b/librpc/rpc/dcesrv_handles.c index d50831bcf0a..cb8b70300cc 100644 --- a/librpc/rpc/dcesrv_handles.c +++ b/librpc/rpc/dcesrv_handles.c @@ -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",