commit - 5e36945a5e19c646c571b6400ed1cb5a0871257f
commit + 694ec0880553af9db8df9b0ea713be7755c1fd00
blob - afdb73f243f7eb2c842352a4ea6475931d9a2246
blob + 6e5fce04845d132173effad6e2394a580d27e17a
--- server_http.c
+++ server_http.c
-/* $OpenBSD: server_http.c,v 1.158 2026/02/02 13:37:33 claudio Exp $ */
+/* $OpenBSD: server_http.c,v 1.159 2026/02/26 19:49:41 claudio Exp $ */
/*
* Copyright (c) 2020 Matthias Pressfreund <mpfr@fn.de>
} else if (desc->http_method != HTTP_METHOD_NONE &&
strcasecmp("Content-Length", key) == 0) {
- if (desc->http_method == HTTP_METHOD_TRACE ||
- desc->http_method == HTTP_METHOD_CONNECT) {
- /*
- * These method should not have a body
- * and thus no Content-Length header.
- */
- server_abort_http(clt, 400, "malformed");
- goto abort;
- }
-
/*
* Need to read data from the client after the
* HTTP header.
switch (desc->http_method) {
case HTTP_METHOD_CONNECT:
+ /* No body allowed */
+ if (clt->clt_toread > 0 || desc->http_chunked) {
+ server_abort_http(clt, 400, "malformed");
+ return;
+ }
/* Data stream */
clt->clt_toread = TOREAD_UNLIMITED;
bev->readcb = server_read;
/* WebDAV methods */
case HTTP_METHOD_COPY:
case HTTP_METHOD_MOVE:
+ /*
+ * These method should not have a body and thus no
+ * Content-Length or Transfer-Encoding: chunked header.
+ */
+ if (clt->clt_toread > 0 || desc->http_chunked) {
+ server_abort_http(clt, 400, "malformed");
+ return;
+ }
clt->clt_toread = 0;
break;
case HTTP_METHOD_DELETE:
/* 7. of RFC 9112 Section 6.3 */
clt->clt_toread = 0;
break;
+ case HTTP_METHOD_TRACE:
default:
server_abort_http(clt, 405, "method not allowed");
return;