]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Remove infinite loop in MSNT auth helper
authorAmos Jeffries <squid3@treenet.co.nz>
Sat, 23 May 2009 04:48:46 +0000 (16:48 +1200)
committerAmos Jeffries <squid3@treenet.co.nz>
Sat, 23 May 2009 04:48:46 +0000 (16:48 +1200)
On one starting error condition the helper enters a read loop
without exit conditions. Made this exit when read was done
and shutdown helper as per behavior comment by the loop.

Also removes one useless goto.

helpers/basic_auth/MSNT/msntauth.c

index 38dd41075764aa1133f65567ab48ebe217655cee..f8eb99f45c0dbfcdeb6427e01ca3ee9732ad219f 100644 (file)
@@ -73,10 +73,13 @@ main(int argc, char **argv)
     if ((Read_denyusers() == 1) || (Read_allowusers() == 1)) {
        while (1) {
            memset(wstr, '\0', sizeof(wstr));
-           fgets(wstr, 255, stdin);
+            if (fgets(wstr, 255, stdin) == NULL)
+                break;
            puts("ERR");
        }
+        return 1;
     }
+
     /*
      * Make Check_forchange() the handle for HUP signals.
      * Don't use alarms any more. I don't think it was very
@@ -98,7 +101,9 @@ main(int argc, char **argv)
        }
        if (err) {
            syslog(LOG_WARNING, "oversized message");
-           goto error;
+           puts("ERR");
+            err = 0;
+            continue;
        }
 
        /*
@@ -114,8 +119,8 @@ main(int argc, char **argv)
        }
        /* Check for invalid or blank entries */
        if ((username[0] == '\0') || (password[0] == '\0')) {
-           puts("ERR");
-           continue;
+            puts("ERR");
+            continue;
        }
        Checktimer();           /* Check if the user lists have changed */
 
@@ -133,10 +138,9 @@ main(int argc, char **argv)
            puts("OK");
        else {
            syslog(LOG_INFO, "'%s' login failed", username);
-error:
-           puts("ERR");
+            puts("ERR");
        }
-       err = 0;
+        err = 0;
     }
 
     return 0;