]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Fixed free() errors in AuthUser::~AuthUser()
authorwessels <>
Wed, 9 May 2007 14:26:57 +0000 (14:26 +0000)
committerwessels <>
Wed, 9 May 2007 14:26:57 +0000 (14:26 +0000)
AuthUser::~AuthUser() was freeing memory in the middle of an allocated
buffer.  I think AuthUser needs a strdup'd copy of the username,
rather than keeping a pointer to the buffer read from the helper.

Also I found 'xfree((char *)username());' really odd.  This username()
method does not return a reference so it shouldn't be used as LHS
in the macro.

src/AuthUser.cc
src/AuthUser.cci
src/AuthUser.h

index c266ee7c136e071f60befb4425b8fe1783ce9b0b..3b829e158f9f555d3d8134c6c61e13975925a688 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: AuthUser.cc,v 1.6 2007/05/09 07:36:24 wessels Exp $
+ * $Id: AuthUser.cc,v 1.7 2007/05/09 08:26:57 wessels Exp $
  *
  * DEBUG: section 29    Authenticator
  * AUTHOR:  Robert Collins
@@ -130,8 +130,8 @@ AuthUser::~AuthUser()
     /* free seen ip address's */
     clearIp();
 
-    if (username())
-        xfree((char *)username());
+    if (username_)
+        xfree((char*)username_);
 
     /* prevent accidental reuse */
     auth_type = AUTH_UNKNOWN;
index d6c754d05ba38f9ddf930b144dfbce7131332c8b..53e89b38e860037ecc9b2373f84de0552375f235 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: AuthUser.cci,v 1.1 2004/08/30 03:28:56 robertc Exp $
+ * $Id: AuthUser.cci,v 1.2 2007/05/09 08:26:57 wessels Exp $
  *
  * DEBUG: section 29    Authenticator
  * AUTHOR:  Robert Collins
@@ -44,7 +44,7 @@ void
 AuthUser::username(char const*aString)
 {
     assert (!username() || !aString);
-    username_ = aString;
+    username_ = xstrdup(aString);
 }
 
 void
index db6dff02b9b032593c6bda0fbedad38559072953..8fa993625b78fadf821b9d4fb06e497e81deb909 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: AuthUser.h,v 1.4 2007/05/09 07:45:58 wessels Exp $
+ * $Id: AuthUser.h,v 1.5 2007/05/09 08:26:57 wessels Exp $
  *
  *
  * SQUID Web Proxy Cache          http://www.squid-cache.org/
@@ -87,6 +87,11 @@ protected:
 private:
     static void cacheCleanup (void *unused);
 
+    /*
+     * DPW 2007-05-08
+     * The username_ memory will be allocated via
+     * xstrdup().  It is our responsibility.
+     */
     char const *username_;
 
     /* what ip addresses has this user been seen at?, plus a list length cache */