]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Fix userinfo percent-encoding (#1367)
authorAlex Rousskov <rousskov@measurement-factory.com>
Thu, 25 May 2023 02:10:28 +0000 (02:10 +0000)
committerAmos Jeffries <yadij@users.noreply.github.com>
Thu, 12 Oct 2023 12:55:26 +0000 (01:55 +1300)
%X expects an unsigned int, and that is what we were giving it. However,
to get to the correct unsigned int value from a (signed) char, one has
to cast to an unsigned char (or equivalent) first.

Broken since inception in commit 7b75100.

Also adjusted similar (commented out) ext_edirectory_userip_acl code.

src/acl/external/eDirectory_userip/ext_edirectory_userip_acl.cc
src/anyp/Uri.cc

index bf124d24f9db7a34bf44097ffb7ee5db1b057173..e3f33e20945539232976d3e6f86b0366735fb0a5 100644 (file)
@@ -1555,7 +1555,7 @@ MainSafe(int argc, char **argv)
         /* BINARY DEBUGGING *
                     local_printfx("while() -> bufa[%" PRIuSIZE "]: %s", k, bufa);
                     for (i = 0; i < k; ++i)
-                      local_printfx("%02X", bufa[i]);
+                      local_printfx("%02X", static_cast<unsigned int>(static_cast<unsigned char>(bufa[i])));
                     local_printfx("\n");
         * BINARY DEBUGGING */
         /* Check for CRLF */
index e372939968b0458ff98a27f92b88e0ad5111aa6a..eca2c23573dc3faefe324953a6c82068d3c66a1f 100644 (file)
@@ -71,7 +71,7 @@ AnyP::Uri::Encode(const SBuf &buf, const CharacterSet &ignore)
     while (!tk.atEnd()) {
         // TODO: Add Tokenizer::parseOne(void).
         const auto ch = tk.remaining()[0];
-        output.appendf("%%%02X", static_cast<unsigned int>(ch)); // TODO: Optimize using a table
+        output.appendf("%%%02X", static_cast<unsigned int>(static_cast<unsigned char>(ch))); // TODO: Optimize using a table
         (void)tk.skip(ch);
 
         if (tk.prefix(goodSection, ignore))