From: amosjeffries <> Date: Tue, 4 Mar 2008 19:08:20 +0000 (+0000) Subject: Optimisation cleanup of fake_auth X-Git-Tag: SQUID_3_0_STABLE2~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9089da9a253469c51e7d8db915459854af8e4190;p=thirdparty%2Fsquid.git Optimisation cleanup of fake_auth strlen() is expensive (particularly on large buffers) and is only needed once here. --- diff --git a/helpers/ntlm_auth/fakeauth/fakeauth_auth.c b/helpers/ntlm_auth/fakeauth/fakeauth_auth.c index bd8e7e44ac..eb4cb51838 100644 --- a/helpers/ntlm_auth/fakeauth/fakeauth_auth.c +++ b/helpers/ntlm_auth/fakeauth/fakeauth_auth.c @@ -369,6 +369,7 @@ int main(int argc, char *argv[]) { char buf[BUFFER_SIZE]; + int buflen = 0; char user[256], *p, *decoded = NULL; struct ntlm_challenge chal; struct ntlm_negotiate *nego; @@ -390,9 +391,10 @@ main(int argc, char *argv[]) if ((p = strchr(buf, '\n')) != NULL) *p = '\0'; /* strip \n */ - if (strlen(buf) > 3) + buflen = strlen(buf); /* keep this so we only scan the buffer for \0 once per loop */ + if (buflen > 3) decoded = base64_decode(buf + 3); - if ((strlen(buf) > 3) && NTLM_packet_debug_enabled) { + if (buflen > 3 && NTLM_packet_debug_enabled) { strncpy(helper_command, buf, 2); helper_command[2] = '\0'; debug("Got '%s' from Squid with data:\n", helper_command); @@ -401,7 +403,7 @@ main(int argc, char *argv[]) debug("Got '%s' from Squid\n", buf); if (strncasecmp(buf, "YR", 2) == 0) { - if (strlen(buf) > 3) { + if(buflen > 3) { nego = (struct ntlm_negotiate *) decoded; ntlmMakeChallenge(&chal, nego->flags); } else