From: amosjeffries <> Date: Fri, 3 Aug 2007 08:07:34 +0000 (+0000) Subject: Add assert()s to validate state in Auth Negotiate X-Git-Tag: SQUID_3_0_PRE7~113 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=27da7c2146a6e470319df445e8823e4873d1fe40;p=thirdparty%2Fsquid.git Add assert()s to validate state in Auth Negotiate Coverity checker picked up a number of cases where casting might (rarely) cause a NULL pointer and a dereference occured afterwards. This patch adds several assert statements to cause squid to abort at the source of these errors rather than segfault later. No code logic has been changed in any way. --- diff --git a/src/auth/negotiate/auth_negotiate.cc b/src/auth/negotiate/auth_negotiate.cc index ac725ef9fd..842522bb07 100644 --- a/src/auth/negotiate/auth_negotiate.cc +++ b/src/auth/negotiate/auth_negotiate.cc @@ -1,6 +1,6 @@ /* - * $Id: auth_negotiate.cc,v 1.22 2007/08/02 04:01:46 amosjeffries Exp $ + * $Id: auth_negotiate.cc,v 1.23 2007/08/03 02:07:34 amosjeffries Exp $ * * DEBUG: section 29 Negotiate Authenticator * AUTHOR: Robert Collins, Henrik Nordstrom, Francesco Chemolli @@ -307,6 +307,8 @@ AuthNegotiateConfig::fixHeader(AuthUserRequest *auth_user_request, HttpReply *re } else { negotiate_request = dynamic_cast(auth_user_request); + assert(negotiate_request != NULL); + switch (negotiate_request->auth_state) { case AUTHENTICATE_STATE_FAILED: @@ -394,6 +396,7 @@ authenticateNegotiateHandleReply(void *data, void *lastserver, char *reply) assert(auth_user_request != NULL); negotiate_request = dynamic_cast(auth_user_request); + assert(negotiate_request != NULL); assert(negotiate_request->waiting); negotiate_request->waiting = 0; safe_free(negotiate_request->client_blob); @@ -403,6 +406,8 @@ authenticateNegotiateHandleReply(void *data, void *lastserver, char *reply) assert(auth_user->auth_type == AUTH_NEGOTIATE); negotiate_user = dynamic_cast(auth_user_request->user()); + assert(negotiate_user != NULL); + if (negotiate_request->authserver == NULL) negotiate_request->authserver = static_cast(lastserver); else @@ -590,6 +595,7 @@ authenticateNegotiateReleaseServer(AuthUserRequest * auth_user_request) * code-paths. Kinkie */ /* DPW 2007-05-07 * yes, it is possible */ + assert(negotiate_request != NULL); if (negotiate_request->authserver) { helperStatefulReleaseServer(negotiate_request->authserver); negotiate_request->authserver = NULL;