Skip to contentSkip to conversation

socks.c: fix check on get_user_pass() return value(s)

PATCH In review Steffan Karger 2 participants 2 messages Jan 13, 2016 – Jan 15, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 socks.c: fix check on get_user_pass() return value(s)

My compiler rightfully complains that the checks on creds.username and creds.password always evaluate to true, so remove those checks.

Judging from the code, they were meant to check the returned values by get_user_pass(). So instead of these non-functioning checks, just check the return value of get_user_pass().

---
 src/openvpn/socks.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
src/openvpn/socks.c +6 -3
index 72bdf55..cef7a35 100644
@@ -103,10 +103,13 @@ socks_username_password_auth (struct socks_proxy_info *p,
   ssize_t size;
 
   creds.defined = 0;
-  get_user_pass (&creds, p->authfile, UP_TYPE_SOCKS, GET_USER_PASS_MANAGEMENT);
+  if (!get_user_pass (&creds, p->authfile, UP_TYPE_SOCKS, GET_USER_PASS_MANAGEMENT))
+    {
+      msg (M_NONFATAL, "SOCKS failed to get username/password.");
+      return false;
+    }
 
-  if( !creds.username || (strlen(creds.username) > 255)
-      || !creds.password || (strlen(creds.password) > 255) ) {
+  if( (strlen(creds.username) > 255) || (strlen(creds.password) > 255) ) {
           msg (M_NONFATAL,
                "SOCKS username and/or password exceeds 255 characters.  "
                "Authentication not possible.");
Signature · 1 line
2.5.0
#1 lore raw

ACK. Makes sense.

Your patch has been applied to the master and release/2.3 branch.

commit 982ab2364a68f2fca0cb9219b31bdabcd5aa4b49 (master) commit 8a64911dbce0718ac2737a172d6e94d21e277621 (release/2.3)

Author: Steffan Karger
Date:   Wed Jan 13 17:09:08 2016 +0100
     socks.c: fix check on get_user_pass() return value(s)

     Signed-off-by: Steffan Karger <[email protected]...>
     Acked-by: Gert Doering <[email protected]...>
     Message-Id: <[email protected]...>
     URL: http://article.gmane.org/gmane.network.openvpn.devel/10993
     Signed-off-by: Gert Doering <[email protected]...>

--
kind regards,

Gert Doering