From: Arne Schwabe Date: Tue, 21 Jan 2025 16:12:47 +0000 (+0100) Subject: Remove comparing username to NULL in tls_lock_username X-Git-Tag: v2.7_alpha1~110 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d9af13e8c222cba41000202908663a6d1e2cd028;p=thirdparty%2Fopenvpn.git Remove comparing username to NULL in tls_lock_username tls_lock_username is only called in a single place and that place calls this is function with up->username, which is always defined. Change-Id: Ib8adf7b31cae02e2de3d45da23b76a2d79f13e20 Signed-off-by: Arne Schwabe Acked-by: Frank Lichtenheld Message-Id: <20250121161247.37883-1-frank@lichtenheld.com> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg30520.html Signed-off-by: Gert Doering --- diff --git a/src/openvpn/ssl_verify.c b/src/openvpn/ssl_verify.c index 4c4b58d64..e7d7ed6f5 100644 --- a/src/openvpn/ssl_verify.c +++ b/src/openvpn/ssl_verify.c @@ -153,11 +153,11 @@ tls_lock_username(struct tls_multi *multi, const char *username) { if (multi->locked_username) { - if (!username || strcmp(username, multi->locked_username)) + if (strcmp(username, multi->locked_username) != 0) { msg(D_TLS_ERRORS, "TLS Auth Error: username attempted to change from '%s' to '%s' -- tunnel disabled", multi->locked_username, - np(username)); + username); /* disable the tunnel */ tls_deauthenticate(multi); @@ -166,10 +166,7 @@ tls_lock_username(struct tls_multi *multi, const char *username) } else { - if (username) - { - multi->locked_username = string_alloc(username, NULL); - } + multi->locked_username = string_alloc(username, NULL); } return true; }