]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Add assert()s to validate state in Basic Auth
authoramosjeffries <>
Fri, 3 Aug 2007 08:11:17 +0000 (08:11 +0000)
committeramosjeffries <>
Fri, 3 Aug 2007 08:11:17 +0000 (08:11 +0000)
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.

src/auth/basic/auth_basic.cc

index e0f99e1e64e4bbcddf976bc880807aa79e043990..3e6f6559084addd3d71e14e53e9436b34c73e616 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: auth_basic.cc,v 1.51 2007/08/02 04:18:14 amosjeffries Exp $
+ * $Id: auth_basic.cc,v 1.52 2007/08/03 02:11:17 amosjeffries Exp $
  *
  * DEBUG: section 29    Authenticator
  * AUTHOR: Duane Wessels
@@ -259,6 +259,8 @@ authenticateBasicHandleReply(void *data, char *reply)
     assert(r->auth_user_request->user()->auth_type == AUTH_BASIC);
     basic_data *basic_auth = dynamic_cast<basic_data *>(r->auth_user_request->user());
 
+    assert(basic_auth != NULL);
+
     if (reply && (strncasecmp(reply, "OK", 2) == 0))
         basic_auth->flags.credentials_ok = 1;
     else {
@@ -642,6 +644,7 @@ AuthBasicUserRequest::module_start(RH * handler, void *data)
     basic_data *basic_auth;
     assert(user()->auth_type == AUTH_BASIC);
     basic_auth = dynamic_cast<basic_data *>(user());
+    assert(basic_auth != NULL);
     debugs(29, 9, "AuthBasicUserRequest::start: '" << basic_auth->username() << ":" << basic_auth->passwd << "'");
 
     if (basicConfig.authenticate == NULL) {