From: Alex Rousskov Date: Fri, 3 Feb 2012 23:48:48 +0000 (-0700) Subject: Fixed Ssl::CertificateProperties::dbKey() to always reset the accumulation buf. X-Git-Tag: BumpSslServerFirst.take05~25 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7fc31d31dc84c2118ed93e68ad1b7dc250d1d98a;p=thirdparty%2Fsquid.git Fixed Ssl::CertificateProperties::dbKey() to always reset the accumulation buf. Also use append instead of assignment, just in case the assignment operator frees previously reserve()d memory. --- diff --git a/src/ssl/gadgets.cc b/src/ssl/gadgets.cc index 557a70a67e..62895d2914 100644 --- a/src/ssl/gadgets.cc +++ b/src/ssl/gadgets.cc @@ -193,14 +193,17 @@ Ssl::CertificateProperties::CertificateProperties(): serial(NULL), std::string & Ssl::CertificateProperties::dbKey() const { static std::string certKey; + certKey.clear(); certKey.reserve(4096); if (mimicCert.get()) { char buf[1024]; - certKey = X509_NAME_oneline(X509_get_subject_name(mimicCert.get()), buf, sizeof(buf)); + certKey.append(X509_NAME_oneline(X509_get_subject_name(mimicCert.get()), buf, sizeof(buf))); } - if (certKey.empty()) - certKey = "/CN=" + commonName; + if (certKey.empty()) { + certKey.append("/CN=", 4); + certKey.append(commonName); + } if (setValidAfter) certKey.append("+SetValidAfter=on", 17);