Browse code

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().

Signed-off-by: Steffan Karger <steffan@karger.me>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1452701348-9577-1-git-send-email-steffan@karger.me>
URL: http://article.gmane.org/gmane.network.openvpn.devel/10993
Signed-off-by: Gert Doering <gert@greenie.muc.de>

Steffan Karger authored on 2016/01/14 01:09:08
Showing 1 changed files
... ...
@@ -103,10 +103,13 @@ socks_username_password_auth (struct socks_proxy_info *p,
103 103
   ssize_t size;
104 104
 
105 105
   creds.defined = 0;
106
-  get_user_pass (&creds, p->authfile, UP_TYPE_SOCKS, GET_USER_PASS_MANAGEMENT);
106
+  if (!get_user_pass (&creds, p->authfile, UP_TYPE_SOCKS, GET_USER_PASS_MANAGEMENT))
107
+    {
108
+      msg (M_NONFATAL, "SOCKS failed to get username/password.");
109
+      return false;
110
+    }
107 111
 
108
-  if( !creds.username || (strlen(creds.username) > 255)
109
-      || !creds.password || (strlen(creds.password) > 255) ) {
112
+  if( (strlen(creds.username) > 255) || (strlen(creds.password) > 255) ) {
110 113
           msg (M_NONFATAL,
111 114
                "SOCKS username and/or password exceeds 255 characters.  "
112 115
                "Authentication not possible.");