summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Spooren2026-04-16 09:10:36 +0000
committerPaul Spooren2026-04-16 09:10:36 +0000
commite619cb04cddba8316d6928ff99f55a49e6ddc561 (patch)
tree72d2edb49bd52e1629f0b351063898d0338ed580
parent506e24987b97fbc866005bfb71316bd63601a1ef (diff)
downloaduhttpd-e619cb04cddba8316d6928ff99f55a49e6ddc561.tar.gz
client: use base-10 parsing for Content-Length header
strtoul() with base 0 auto-detects octal (leading "0") and hexadecimal (leading "0x") prefixes. A Content-Length value like "025" was parsed as octal 21 instead of decimal 25. Since compliant HTTP frontends always parse Content-Length as decimal per RFC 7230, this mismatch enables HTTP request smuggling when uhttpd sits behind a reverse proxy or load balancer. Fix by explicitly passing base 10 to strtoul(). Reported-by: Nicola Staller <nicola.staller@syss.de> Signed-off-by: Paul Spooren <mail@aparcar.org>
-rw-r--r--client.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/client.c b/client.c
index 1d302d7..4d343fe 100644
--- a/client.c
+++ b/client.c
@@ -391,7 +391,7 @@ static void client_parse_header(struct client *cl, char *data)
return;
}
} else if (!strcmp(data, "content-length")) {
- r->content_length = strtoul(val, &err, 0);
+ r->content_length = strtoul(val, &err, 10);
if ((err && *err) || r->content_length < 0) {
uh_header_error(cl, 400, "Bad Request");
return;