diff -u -r -N squid-5.0.7/ChangeLog squid-5.1/ChangeLog
--- squid-5.0.7/ChangeLog	2021-07-05 20:27:18.000000000 +1200
+++ squid-5.1/ChangeLog	2021-07-31 18:54:23.000000000 +1200
@@ -1,3 +1,11 @@
+Changes in squid-5.1 (01 Aug 2021):
+
+	- Bug 4696: Fix leaky String move assignment operator
+	- Fix ACL-related reconfiguration memory leak
+	- Fix SSL-Bump reconfiguration leaking public key memory
+	- Fix build on RISC-V
+	- Fix build on Ubuntu 21.04
+
 Changes in squid-5.0.7 (04 Jul 2021):
 
 	- Fix a helper logging issues
diff -u -r -N squid-5.0.7/configure squid-5.1/configure
--- squid-5.0.7/configure	2021-07-05 22:41:19.000000000 +1200
+++ squid-5.1/configure	2021-07-31 21:05:32.000000000 +1200
@@ -1,7 +1,7 @@
 #! /bin/sh
 # From configure.ac Revision.
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.69 for Squid Web Proxy 5.0.7.
+# Generated by GNU Autoconf 2.69 for Squid Web Proxy 5.1.
 #
 # Report bugs to <http://bugs.squid-cache.org/>.
 #
@@ -595,8 +595,8 @@
 # Identity of this package.
 PACKAGE_NAME='Squid Web Proxy'
 PACKAGE_TARNAME='squid'
-PACKAGE_VERSION='5.0.7'
-PACKAGE_STRING='Squid Web Proxy 5.0.7'
+PACKAGE_VERSION='5.1'
+PACKAGE_STRING='Squid Web Proxy 5.1'
 PACKAGE_BUGREPORT='http://bugs.squid-cache.org/'
 PACKAGE_URL=''
 
@@ -1662,7 +1662,7 @@
   # Omit some internal or obsolete options to make the list less imposing.
   # This message is too long to be a string in the A/UX 3.1 sh.
   cat <<_ACEOF
-\`configure' configures Squid Web Proxy 5.0.7 to adapt to many kinds of systems.
+\`configure' configures Squid Web Proxy 5.1 to adapt to many kinds of systems.
 
 Usage: $0 [OPTION]... [VAR=VALUE]...
 
@@ -1733,7 +1733,7 @@
 
 if test -n "$ac_init_help"; then
   case $ac_init_help in
-     short | recursive ) echo "Configuration of Squid Web Proxy 5.0.7:";;
+     short | recursive ) echo "Configuration of Squid Web Proxy 5.1:";;
    esac
   cat <<\_ACEOF
 
@@ -2166,7 +2166,7 @@
 test -n "$ac_init_help" && exit $ac_status
 if $ac_init_version; then
   cat <<\_ACEOF
-Squid Web Proxy configure 5.0.7
+Squid Web Proxy configure 5.1
 generated by GNU Autoconf 2.69
 
 Copyright (C) 2012 Free Software Foundation, Inc.
@@ -3270,7 +3270,7 @@
 This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
 
-It was created by Squid Web Proxy $as_me 5.0.7, which was
+It was created by Squid Web Proxy $as_me 5.1, which was
 generated by GNU Autoconf 2.69.  Invocation command line was
 
   $ $0 $@
@@ -4132,7 +4132,7 @@
 
 # Define the identity of the package.
  PACKAGE='squid'
- VERSION='5.0.7'
+ VERSION='5.1'
 
 
 cat >>confdefs.h <<_ACEOF
@@ -21121,8 +21121,11 @@
 #include <atomic>
 #include <cstdint>
       int
-      main(int, char **) {
-          return std::atomic<uint64_t>{}.is_lock_free() ? 0 : 1;
+      main(int argc, char **) {
+          return (
+              std::atomic<uint8_t>(uint8_t(argc)).exchange(0) &&
+              std::atomic<uint64_t>{}.is_lock_free()
+              ) ? 0 : 1;
       }
 
 _ACEOF
@@ -21153,8 +21156,11 @@
 #include <atomic>
 #include <cstdint>
       int
-      main(int, char **) {
-          return std::atomic<uint64_t>{}.is_lock_free() ? 0 : 1;
+      main(int argc, char **) {
+          return (
+              std::atomic<uint8_t>(uint8_t(argc)).exchange(0) &&
+              std::atomic<uint64_t>{}.is_lock_free()
+              ) ? 0 : 1;
       }
 
 _ACEOF
@@ -45093,7 +45099,7 @@
 # report actual input values of CONFIG_FILES etc. instead of their
 # values after options handling.
 ac_log="
-This file was extended by Squid Web Proxy $as_me 5.0.7, which was
+This file was extended by Squid Web Proxy $as_me 5.1, which was
 generated by GNU Autoconf 2.69.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
@@ -45159,7 +45165,7 @@
 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
 ac_cs_version="\\
-Squid Web Proxy config.status 5.0.7
+Squid Web Proxy config.status 5.1
 configured by $0, generated by GNU Autoconf 2.69,
   with options \\"\$ac_cs_config\\"
 
diff -u -r -N squid-5.0.7/configure.ac squid-5.1/configure.ac
--- squid-5.0.7/configure.ac	2021-07-05 22:41:19.000000000 +1200
+++ squid-5.1/configure.ac	2021-07-31 21:05:32.000000000 +1200
@@ -5,7 +5,7 @@
 ## Please see the COPYING and CONTRIBUTORS files for details.
 ##
 
-AC_INIT([Squid Web Proxy],[5.0.7],[http://bugs.squid-cache.org/],[squid])
+AC_INIT([Squid Web Proxy],[5.1],[http://bugs.squid-cache.org/],[squid])
 AC_PREREQ(2.61)
 AC_CONFIG_HEADERS([include/autoconf.h])
 AC_CONFIG_AUX_DIR(cfgaux)
@@ -447,8 +447,11 @@
 #include <atomic>
 #include <cstdint>
       int
-      main(int, char **) {
-          return std::atomic<uint64_t>{}.is_lock_free() ? 0 : 1;
+      main(int argc, char **) {
+          return (
+              std::atomic<uint8_t>(uint8_t(argc)).exchange(0) &&
+              std::atomic<uint64_t>{}.is_lock_free()
+              ) ? 0 : 1;
       }
   ]])],[
     AC_MSG_RESULT(yes)
diff -u -r -N squid-5.0.7/doc/release-notes/release-5.html squid-5.1/doc/release-notes/release-5.html
--- squid-5.0.7/doc/release-notes/release-5.html	2021-07-05 22:45:43.000000000 +1200
+++ squid-5.1/doc/release-notes/release-5.html	2021-07-31 21:10:13.000000000 +1200
@@ -3,10 +3,10 @@
 <HEAD>
  <META NAME="GENERATOR" CONTENT="LinuxDoc-Tools 0.9.82">
  <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
- <TITLE>Squid 5.0.7 release notes</TITLE>
+ <TITLE>Squid 5.1 release notes</TITLE>
 </HEAD>
 <BODY>
-<H1>Squid 5.0.7 release notes</H1>
+<H1>Squid 5.1 release notes</H1>
 
 <H2>Squid Developers</H2>
 <HR>
@@ -61,13 +61,11 @@
 <HR>
 <H2><A NAME="s1">1.</A> <A HREF="#toc1">Notice</A></H2>
 
-<P>The Squid Team are pleased to announce the release of Squid-5.0.7 for testing.</P>
+<P>The Squid Team are pleased to announce the release of Squid-5.1.</P>
 <P>This new release is available for download from 
 <A HREF="http://www.squid-cache.org/Versions/v5/">http://www.squid-cache.org/Versions/v5/</A> or the
 <A HREF="http://www.squid-cache.org/Download/http-mirrors.html">mirrors</A>.</P>
 
-<P>While this release is not deemed ready for production use, we believe it is ready for wider testing by the community.</P>
-
 <P>We welcome feedback and bug reports. If you find a bug, please see 
 <A HREF="http://wiki.squid-cache.org/SquidFaq/BugReporting">http://wiki.squid-cache.org/SquidFaq/BugReporting</A>
 for how to submit a report with a stack trace.</P>
diff -u -r -N squid-5.0.7/include/version.h squid-5.1/include/version.h
--- squid-5.0.7/include/version.h	2021-07-05 22:41:19.000000000 +1200
+++ squid-5.1/include/version.h	2021-07-31 21:05:32.000000000 +1200
@@ -7,7 +7,7 @@
  */
 
 #ifndef SQUID_RELEASE_TIME
-#define SQUID_RELEASE_TIME 1625481669
+#define SQUID_RELEASE_TIME 1627722321
 #endif
 
 /*
diff -u -r -N squid-5.0.7/RELEASENOTES.html squid-5.1/RELEASENOTES.html
--- squid-5.0.7/RELEASENOTES.html	2021-07-05 22:45:43.000000000 +1200
+++ squid-5.1/RELEASENOTES.html	2021-07-31 21:10:13.000000000 +1200
@@ -3,10 +3,10 @@
 <HEAD>
  <META NAME="GENERATOR" CONTENT="LinuxDoc-Tools 0.9.82">
  <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
- <TITLE>Squid 5.0.7 release notes</TITLE>
+ <TITLE>Squid 5.1 release notes</TITLE>
 </HEAD>
 <BODY>
-<H1>Squid 5.0.7 release notes</H1>
+<H1>Squid 5.1 release notes</H1>
 
 <H2>Squid Developers</H2>
 <HR>
@@ -61,13 +61,11 @@
 <HR>
 <H2><A NAME="s1">1.</A> <A HREF="#toc1">Notice</A></H2>
 
-<P>The Squid Team are pleased to announce the release of Squid-5.0.7 for testing.</P>
+<P>The Squid Team are pleased to announce the release of Squid-5.1.</P>
 <P>This new release is available for download from 
 <A HREF="http://www.squid-cache.org/Versions/v5/">http://www.squid-cache.org/Versions/v5/</A> or the
 <A HREF="http://www.squid-cache.org/Download/http-mirrors.html">mirrors</A>.</P>
 
-<P>While this release is not deemed ready for production use, we believe it is ready for wider testing by the community.</P>
-
 <P>We welcome feedback and bug reports. If you find a bug, please see 
 <A HREF="http://wiki.squid-cache.org/SquidFaq/BugReporting">http://wiki.squid-cache.org/SquidFaq/BugReporting</A>
 for how to submit a report with a stack trace.</P>
diff -u -r -N squid-5.0.7/src/acl/external/delayer/ext_delayer_acl.8 squid-5.1/src/acl/external/delayer/ext_delayer_acl.8
--- squid-5.0.7/src/acl/external/delayer/ext_delayer_acl.8	2021-07-05 22:45:46.000000000 +1200
+++ squid-5.1/src/acl/external/delayer/ext_delayer_acl.8	2021-07-31 21:10:16.000000000 +1200
@@ -133,7 +133,7 @@
 .\" ========================================================================
 .\"
 .IX Title "EXT_DELAYER_ACL 8"
-.TH EXT_DELAYER_ACL 8 "2021-07-05" "perl v5.32.0" "User Contributed Perl Documentation"
+.TH EXT_DELAYER_ACL 8 "2021-07-31" "perl v5.32.0" "User Contributed Perl Documentation"
 .\" For nroff, turn off justification.  Always turn off hyphenation; it makes
 .\" way too many mistakes in technical documents.
 .if n .ad l
diff -u -r -N squid-5.0.7/src/acl/external/kerberos_sid_group/ext_kerberos_sid_group_acl.8 squid-5.1/src/acl/external/kerberos_sid_group/ext_kerberos_sid_group_acl.8
--- squid-5.0.7/src/acl/external/kerberos_sid_group/ext_kerberos_sid_group_acl.8	2021-07-05 22:45:46.000000000 +1200
+++ squid-5.1/src/acl/external/kerberos_sid_group/ext_kerberos_sid_group_acl.8	2021-07-31 21:10:16.000000000 +1200
@@ -133,7 +133,7 @@
 .\" ========================================================================
 .\"
 .IX Title "EXT_KERBEROS_SID_GROUP_ACL 8"
-.TH EXT_KERBEROS_SID_GROUP_ACL 8 "2021-07-05" "perl v5.32.0" "User Contributed Perl Documentation"
+.TH EXT_KERBEROS_SID_GROUP_ACL 8 "2021-07-31" "perl v5.32.0" "User Contributed Perl Documentation"
 .\" For nroff, turn off justification.  Always turn off hyphenation; it makes
 .\" way too many mistakes in technical documents.
 .if n .ad l
diff -u -r -N squid-5.0.7/src/acl/external/SQL_session/ext_sql_session_acl.8 squid-5.1/src/acl/external/SQL_session/ext_sql_session_acl.8
--- squid-5.0.7/src/acl/external/SQL_session/ext_sql_session_acl.8	2021-07-05 22:45:46.000000000 +1200
+++ squid-5.1/src/acl/external/SQL_session/ext_sql_session_acl.8	2021-07-31 21:10:16.000000000 +1200
@@ -133,7 +133,7 @@
 .\" ========================================================================
 .\"
 .IX Title "EXT_SQL_SESSION_ACL 8"
-.TH EXT_SQL_SESSION_ACL 8 "2021-07-05" "perl v5.32.0" "User Contributed Perl Documentation"
+.TH EXT_SQL_SESSION_ACL 8 "2021-07-31" "perl v5.32.0" "User Contributed Perl Documentation"
 .\" For nroff, turn off justification.  Always turn off hyphenation; it makes
 .\" way too many mistakes in technical documents.
 .if n .ad l
diff -u -r -N squid-5.0.7/src/acl/external/wbinfo_group/ext_wbinfo_group_acl.8 squid-5.1/src/acl/external/wbinfo_group/ext_wbinfo_group_acl.8
--- squid-5.0.7/src/acl/external/wbinfo_group/ext_wbinfo_group_acl.8	2021-07-05 22:45:46.000000000 +1200
+++ squid-5.1/src/acl/external/wbinfo_group/ext_wbinfo_group_acl.8	2021-07-31 21:10:16.000000000 +1200
@@ -133,7 +133,7 @@
 .\" ========================================================================
 .\"
 .IX Title "EXT_WBINFO_GROUP_ACL 8"
-.TH EXT_WBINFO_GROUP_ACL 8 "2021-07-05" "perl v5.32.0" "User Contributed Perl Documentation"
+.TH EXT_WBINFO_GROUP_ACL 8 "2021-07-31" "perl v5.32.0" "User Contributed Perl Documentation"
 .\" For nroff, turn off justification.  Always turn off hyphenation; it makes
 .\" way too many mistakes in technical documents.
 .if n .ad l
diff -u -r -N squid-5.0.7/src/acl/Strategised.h squid-5.1/src/acl/Strategised.h
--- squid-5.0.7/src/acl/Strategised.h	2021-07-05 20:27:18.000000000 +1200
+++ squid-5.1/src/acl/Strategised.h	2021-07-31 18:54:23.000000000 +1200
@@ -64,6 +64,7 @@
 ACLStrategised<MatchType>::~ACLStrategised()
 {
     delete data;
+    delete matcher;
 }
 
 template <class MatchType>
diff -u -r -N squid-5.0.7/src/auth/basic/DB/basic_db_auth.8 squid-5.1/src/auth/basic/DB/basic_db_auth.8
--- squid-5.0.7/src/auth/basic/DB/basic_db_auth.8	2021-07-05 22:45:47.000000000 +1200
+++ squid-5.1/src/auth/basic/DB/basic_db_auth.8	2021-07-31 21:10:17.000000000 +1200
@@ -133,7 +133,7 @@
 .\" ========================================================================
 .\"
 .IX Title "BASIC_DB_AUTH 8"
-.TH BASIC_DB_AUTH 8 "2021-07-05" "perl v5.32.0" "User Contributed Perl Documentation"
+.TH BASIC_DB_AUTH 8 "2021-07-31" "perl v5.32.0" "User Contributed Perl Documentation"
 .\" For nroff, turn off justification.  Always turn off hyphenation; it makes
 .\" way too many mistakes in technical documents.
 .if n .ad l
diff -u -r -N squid-5.0.7/src/auth/basic/POP3/basic_pop3_auth.8 squid-5.1/src/auth/basic/POP3/basic_pop3_auth.8
--- squid-5.0.7/src/auth/basic/POP3/basic_pop3_auth.8	2021-07-05 22:45:47.000000000 +1200
+++ squid-5.1/src/auth/basic/POP3/basic_pop3_auth.8	2021-07-31 21:10:17.000000000 +1200
@@ -133,7 +133,7 @@
 .\" ========================================================================
 .\"
 .IX Title "BASIC_POP3_AUTH 8"
-.TH BASIC_POP3_AUTH 8 "2021-07-05" "perl v5.32.0" "User Contributed Perl Documentation"
+.TH BASIC_POP3_AUTH 8 "2021-07-31" "perl v5.32.0" "User Contributed Perl Documentation"
 .\" For nroff, turn off justification.  Always turn off hyphenation; it makes
 .\" way too many mistakes in technical documents.
 .if n .ad l
diff -u -r -N squid-5.0.7/src/http/url_rewriters/LFS/url_lfs_rewrite.8 squid-5.1/src/http/url_rewriters/LFS/url_lfs_rewrite.8
--- squid-5.0.7/src/http/url_rewriters/LFS/url_lfs_rewrite.8	2021-07-05 22:45:48.000000000 +1200
+++ squid-5.1/src/http/url_rewriters/LFS/url_lfs_rewrite.8	2021-07-31 21:10:18.000000000 +1200
@@ -133,7 +133,7 @@
 .\" ========================================================================
 .\"
 .IX Title "URL_LFS_REWRITE 8"
-.TH URL_LFS_REWRITE 8 "2021-07-05" "perl v5.32.0" "User Contributed Perl Documentation"
+.TH URL_LFS_REWRITE 8 "2021-07-31" "perl v5.32.0" "User Contributed Perl Documentation"
 .\" For nroff, turn off justification.  Always turn off hyphenation; it makes
 .\" way too many mistakes in technical documents.
 .if n .ad l
diff -u -r -N squid-5.0.7/src/log/DB/log_db_daemon.8 squid-5.1/src/log/DB/log_db_daemon.8
--- squid-5.0.7/src/log/DB/log_db_daemon.8	2021-07-05 22:45:48.000000000 +1200
+++ squid-5.1/src/log/DB/log_db_daemon.8	2021-07-31 21:10:19.000000000 +1200
@@ -133,7 +133,7 @@
 .\" ========================================================================
 .\"
 .IX Title "LOG_DB_DAEMON 8"
-.TH LOG_DB_DAEMON 8 "2021-07-05" "perl v5.32.0" "User Contributed Perl Documentation"
+.TH LOG_DB_DAEMON 8 "2021-07-31" "perl v5.32.0" "User Contributed Perl Documentation"
 .\" For nroff, turn off justification.  Always turn off hyphenation; it makes
 .\" way too many mistakes in technical documents.
 .if n .ad l
diff -u -r -N squid-5.0.7/src/security/cert_validators/fake/security_fake_certverify.8 squid-5.1/src/security/cert_validators/fake/security_fake_certverify.8
--- squid-5.0.7/src/security/cert_validators/fake/security_fake_certverify.8	2021-07-05 22:45:49.000000000 +1200
+++ squid-5.1/src/security/cert_validators/fake/security_fake_certverify.8	2021-07-31 21:10:19.000000000 +1200
@@ -133,7 +133,7 @@
 .\" ========================================================================
 .\"
 .IX Title "SECURITY_FAKE_CERTVERIFY 8"
-.TH SECURITY_FAKE_CERTVERIFY 8 "2021-07-05" "perl v5.32.0" "User Contributed Perl Documentation"
+.TH SECURITY_FAKE_CERTVERIFY 8 "2021-07-31" "perl v5.32.0" "User Contributed Perl Documentation"
 .\" For nroff, turn off justification.  Always turn off hyphenation; it makes
 .\" way too many mistakes in technical documents.
 .if n .ad l
diff -u -r -N squid-5.0.7/src/SquidString.h squid-5.1/src/SquidString.h
--- squid-5.0.7/src/SquidString.h	2021-07-05 20:27:18.000000000 +1200
+++ squid-5.1/src/SquidString.h	2021-07-31 18:54:23.000000000 +1200
@@ -42,6 +42,7 @@
     String &operator =(String const &);
     String &operator =(String && S) {
         if (this != &S) {
+            clean();
             size_ = S.size_;
             len_ = S.len_;
             buf_ = S.buf_;
diff -u -r -N squid-5.0.7/src/ssl/gadgets.cc squid-5.1/src/ssl/gadgets.cc
--- squid-5.0.7/src/ssl/gadgets.cc	2021-07-05 20:27:18.000000000 +1200
+++ squid-5.1/src/ssl/gadgets.cc	2021-07-31 18:54:23.000000000 +1200
@@ -376,8 +376,10 @@
         DecipherOnly
     };
 
-    EVP_PKEY *certKey = X509_get_pubkey(mimicCert.get());
-    const bool rsaPkey = (EVP_PKEY_get0_RSA(certKey) != nullptr);
+    // XXX: Add PublicKeyPointer. In OpenSSL, public and private keys are
+    // internally represented by EVP_PKEY pair, but GnuTLS uses distinct types.
+    const Security::PrivateKeyPointer certKey(X509_get_pubkey(mimicCert.get()));
+    const auto rsaPkey = EVP_PKEY_get0_RSA(certKey.get()) != nullptr;
 
     int added = 0;
     int nid;
diff -u -r -N squid-5.0.7/src/store/id_rewriters/file/storeid_file_rewrite.8 squid-5.1/src/store/id_rewriters/file/storeid_file_rewrite.8
--- squid-5.0.7/src/store/id_rewriters/file/storeid_file_rewrite.8	2021-07-05 22:45:47.000000000 +1200
+++ squid-5.1/src/store/id_rewriters/file/storeid_file_rewrite.8	2021-07-31 21:10:17.000000000 +1200
@@ -133,7 +133,7 @@
 .\" ========================================================================
 .\"
 .IX Title "STOREID_FILE_REWRITE 8"
-.TH STOREID_FILE_REWRITE 8 "2021-07-05" "perl v5.32.0" "User Contributed Perl Documentation"
+.TH STOREID_FILE_REWRITE 8 "2021-07-31" "perl v5.32.0" "User Contributed Perl Documentation"
 .\" For nroff, turn off justification.  Always turn off hyphenation; it makes
 .\" way too many mistakes in technical documents.
 .if n .ad l
diff -u -r -N squid-5.0.7/src/tools.cc squid-5.1/src/tools.cc
--- squid-5.0.7/src/tools.cc	2021-07-05 20:27:18.000000000 +1200
+++ squid-5.1/src/tools.cc	2021-07-31 18:54:23.000000000 +1200
@@ -582,7 +582,10 @@
     }
 #else
 
-    setuid(0);
+    if (setuid(0) < 0) {
+        const auto xerrno = errno;
+        debugs(21, 3, "setuid(0) failed: " << xstrerr(xerrno));
+    }
 #endif
 #if HAVE_PRCTL && defined(PR_SET_DUMPABLE)
     /* Set Linux DUMPABLE flag */
diff -u -r -N squid-5.0.7/tools/helper-mux/helper-mux.8 squid-5.1/tools/helper-mux/helper-mux.8
--- squid-5.0.7/tools/helper-mux/helper-mux.8	2021-07-05 22:45:49.000000000 +1200
+++ squid-5.1/tools/helper-mux/helper-mux.8	2021-07-31 21:10:19.000000000 +1200
@@ -133,7 +133,7 @@
 .\" ========================================================================
 .\"
 .IX Title "HELPER-MUX 8"
-.TH HELPER-MUX 8 "2021-07-05" "perl v5.32.0" "User Contributed Perl Documentation"
+.TH HELPER-MUX 8 "2021-07-31" "perl v5.32.0" "User Contributed Perl Documentation"
 .\" For nroff, turn off justification.  Always turn off hyphenation; it makes
 .\" way too many mistakes in technical documents.
 .if n .ad l
