Skip to content

Commit

Permalink
Fix userinfo percent-encoding (#1367)
Browse files Browse the repository at this point in the history
%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.
  • Loading branch information
rousskov authored and yadij committed Oct 12, 2023
1 parent d189b5a commit 7de0196
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
Expand Up @@ -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 */
Expand Down
2 changes: 1 addition & 1 deletion src/anyp/Uri.cc
Expand Up @@ -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))
Expand Down

0 comments on commit 7de0196

Please sign in to comment.