From: Amos Jeffries Date: Sat, 23 May 2009 04:48:46 +0000 (+1200) Subject: Remove infinite loop in MSNT auth helper X-Git-Tag: SQUID_3_0_STABLE16~19 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8bab6e74ac3e616f8bd73335af9fae3716b7d809;p=thirdparty%2Fsquid.git Remove infinite loop in MSNT auth helper 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. --- diff --git a/helpers/basic_auth/MSNT/msntauth.c b/helpers/basic_auth/MSNT/msntauth.c index 38dd410757..f8eb99f45c 100644 --- a/helpers/basic_auth/MSNT/msntauth.c +++ b/helpers/basic_auth/MSNT/msntauth.c @@ -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;