]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Fix cachemgr.cgi regression in the bug 4957 fix (#741)
authorŠtěpán Brož <32738079+brozs@users.noreply.github.com>
Tue, 27 Oct 2020 10:29:18 +0000 (10:29 +0000)
committerSquid Anubis <squid-anubis@squid-cache.org>
Tue, 27 Oct 2020 11:20:24 +0000 (11:20 +0000)
After master commit 2e29287, authenticated CGI interface users could not
use the menu links (getting HTTP 403 error). Symptoms in cache.log:

    CacheManager: unknown@...: password needed for 'menu'
    CacheManager: <username>@...: incorrect password for 'menu'

tools/cachemgr.cc

index 8c59629324e59977fbe9dff0ad651fe91303432d..0a0d027582a688222ab75fa4832084ceea0c0b25 100644 (file)
@@ -1092,14 +1092,20 @@ make_pub_auth(cachemgr_request * req)
     if (!req->passwd || !strlen(req->passwd))
         return;
 
+    auto *rfc1738_username = xstrdup(rfc1738_escape(safe_str(req->user_name)));
+    auto *rfc1738_passwd = xstrdup(rfc1738_escape(req->passwd));
+
     /* host | time | user | passwd */
     const int bufLen = snprintf(buf, sizeof(buf), "%s|%d|%s|%s",
                                 req->hostname,
                                 (int) now,
-                                rfc1738_escape(safe_str(req->user_name)),
-                                rfc1738_escape(req->passwd));
+                                rfc1738_username,
+                                rfc1738_passwd);
     debug("cmgr: pre-encoded for pub: %s\n", buf);
 
+    safe_free(rfc1738_username);
+    safe_free(rfc1738_passwd);
+
     const int encodedLen = base64_encode_len(bufLen);
     req->pub_auth = (char *) xmalloc(encodedLen);
     struct base64_encode_ctx ctx;