diff --git a/librpc/rpc/dcesrv_handles.c b/librpc/rpc/dcesrv_handles.c index cb8b70300cc..da1f00f5b67 100644 --- a/librpc/rpc/dcesrv_handles.c +++ b/librpc/rpc/dcesrv_handles.c @@ -116,28 +116,36 @@ struct dcesrv_handle *dcesrv_handle_lookup(struct dcesrv_call_state *call, 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 (!dom_sid_equal(&h->sid, sid)) { - struct dom_sid_buf buf1, buf2; - DBG_ERR("Attempt to use invalid sid %s - %s\n", - dom_sid_str_buf(&h->sid, &buf1), - dom_sid_str_buf(sid, &buf2)); - return NULL; - } - if (call->auth_state->auth_level < h->min_auth_level) { - DEBUG(0,(__location__ ": Attempt to use invalid auth_level %u < %u\n", - call->auth_state->auth_level, - h->min_auth_level)); - return NULL; - } - if (h->iface != context->iface) { - DEBUG(0,(__location__ ": Attempt to use invalid iface\n")); - return NULL; - } - return h; + break; } } - return NULL; + if (h == NULL) { + /* not found */ + 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", + dom_sid_str_buf(&h->sid, &buf1), + dom_sid_str_buf(sid, &buf2)); + return NULL; + } + + if (call->auth_state->auth_level < h->min_auth_level) { + DBG_ERR("Attempt to use invalid auth_level %u < %u\n", + call->auth_state->auth_level, + h->min_auth_level); + return NULL; + } + + if (h->iface != context->iface) { + DBG_ERR("Attempt to use invalid iface\n"); + return NULL; + } + + return h; } struct dcesrv_iface_state {