From: wessels <> Date: Wed, 9 May 2007 14:26:57 +0000 (+0000) Subject: Fixed free() errors in AuthUser::~AuthUser() X-Git-Tag: SQUID_3_0_PRE6~5 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=3f5f1a0170e2be74f12247a1c65f495cf5235102;p=thirdparty%2Fsquid.git Fixed free() errors in AuthUser::~AuthUser() 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. --- diff --git a/src/AuthUser.cc b/src/AuthUser.cc index c266ee7c13..3b829e158f 100644 --- a/src/AuthUser.cc +++ b/src/AuthUser.cc @@ -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; diff --git a/src/AuthUser.cci b/src/AuthUser.cci index d6c754d05b..53e89b38e8 100644 --- a/src/AuthUser.cci +++ b/src/AuthUser.cci @@ -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 diff --git a/src/AuthUser.h b/src/AuthUser.h index db6dff02b9..8fa993625b 100644 --- a/src/AuthUser.h +++ b/src/AuthUser.h @@ -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 */