]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Fixed Ssl::CertificateProperties::dbKey() to always reset the accumulation buf.
authorAlex Rousskov <rousskov@measurement-factory.com>
Fri, 3 Feb 2012 23:48:48 +0000 (16:48 -0700)
committerAlex Rousskov <rousskov@measurement-factory.com>
Fri, 3 Feb 2012 23:48:48 +0000 (16:48 -0700)
Also use append instead of assignment, just in case the assignment operator
frees previously reserve()d memory.

src/ssl/gadgets.cc

index 557a70a67eeeadd3f179b55b7b4a3ce9bf30d0c3..62895d291492baf562cefc08b0032b7da80c97d5 100644 (file)
@@ -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);