From: Stefan Metzmacher Date: Tue, 12 Jun 2018 13:39:51 +0000 (+0200) Subject: smbd: simplify the logic in change_to_user() X-Git-Tag: tevent-0.9.37~316 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=35a12e7009d9f1e2eeab06c02ac8227f5b59c778;p=thirdparty%2Fsamba.git smbd: simplify the logic in change_to_user() We can return early if (vuser == NULL). Signed-off-by: Stefan Metzmacher Reviewed-by: Ralph Boehme --- diff --git a/source3/smbd/uid.c b/source3/smbd/uid.c index 0af47831a4d..e100c45a606 100644 --- a/source3/smbd/uid.c +++ b/source3/smbd/uid.c @@ -378,15 +378,6 @@ bool change_to_user(connection_struct *conn, uint64_t vuid) } vuser = get_valid_user_struct(conn->sconn, vuid); - - if ((current_user.conn == conn) && - (vuser != NULL) && (current_user.vuid == vuid) && - (current_user.ut.uid == vuser->session_info->unix_token->uid)) { - DEBUG(4,("Skipping user change - already " - "user\n")); - return(True); - } - if (vuser == NULL) { /* Invalid vuid sent */ DEBUG(2,("Invalid vuid %llu used on share %s.\n", @@ -395,6 +386,14 @@ bool change_to_user(connection_struct *conn, uint64_t vuid) return false; } + if ((current_user.conn == conn) && + (current_user.vuid == vuid) && + (current_user.ut.uid == vuser->session_info->unix_token->uid)) + { + DBG_INFO("Skipping user change - already user\n"); + return true; + } + return change_to_user_internal(conn, vuser->session_info, vuid); }