diff options
author | benno <benno@openbsd.org> | 2018-10-01 19:24:09 +0000 |
---|---|---|
committer | benno <benno@openbsd.org> | 2018-10-01 19:24:09 +0000 |
commit | cf812e09eb20f445631e1c54f4c68e7341945085 (patch) | |
tree | 7dfca04767207ebbe5d923a3d6fa09b2e2e72e18 /usr.sbin/httpd | |
parent | Use inline functions instead of GNU C statement expressions for the MD (diff) | |
download | wireguard-openbsd-cf812e09eb20f445631e1c54f4c68e7341945085.tar.xz wireguard-openbsd-cf812e09eb20f445631e1c54f4c68e7341945085.zip |
Only send 408 Timeout responses when we have seen at least part of a
request. Without a request, just close the connection when we hit
request timeout.
Prompted by a bug report from Nikola Kolev, thanks.
ok reyk@ and some suggestions from claudio@ and bluhm@
Diffstat (limited to 'usr.sbin/httpd')
-rw-r--r-- | usr.sbin/httpd/httpd.h | 11 | ||||
-rw-r--r-- | usr.sbin/httpd/server.c | 8 | ||||
-rw-r--r-- | usr.sbin/httpd/server_http.c | 8 |
3 files changed, 18 insertions, 9 deletions
diff --git a/usr.sbin/httpd/httpd.h b/usr.sbin/httpd/httpd.h index 4b1d9d72237..67cb45e138d 100644 --- a/usr.sbin/httpd/httpd.h +++ b/usr.sbin/httpd/httpd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: httpd.h,v 1.140 2018/09/09 21:06:51 bluhm Exp $ */ +/* $OpenBSD: httpd.h,v 1.141 2018/10/01 19:24:09 benno Exp $ */ /* * Copyright (c) 2006 - 2015 Reyk Floeter <reyk@openbsd.org> @@ -100,10 +100,11 @@ enum httpchunk { TOREAD_UNLIMITED = -1, - TOREAD_HTTP_HEADER = -2, - TOREAD_HTTP_CHUNK_LENGTH = -3, - TOREAD_HTTP_CHUNK_TRAILER = -4, - TOREAD_HTTP_NONE = -5, + TOREAD_HTTP_INIT = -2, + TOREAD_HTTP_HEADER = -3, + TOREAD_HTTP_CHUNK_LENGTH = -4, + TOREAD_HTTP_CHUNK_TRAILER = -5, + TOREAD_HTTP_NONE = -6, TOREAD_HTTP_RANGE = TOREAD_HTTP_CHUNK_LENGTH }; diff --git a/usr.sbin/httpd/server.c b/usr.sbin/httpd/server.c index 5f4304705d8..ef4aa6a2a93 100644 --- a/usr.sbin/httpd/server.c +++ b/usr.sbin/httpd/server.c @@ -1,4 +1,4 @@ -/* $OpenBSD: server.c,v 1.114 2018/05/19 13:56:56 jsing Exp $ */ +/* $OpenBSD: server.c,v 1.115 2018/10/01 19:24:09 benno Exp $ */ /* * Copyright (c) 2006 - 2015 Reyk Floeter <reyk@openbsd.org> @@ -901,7 +901,6 @@ server_input(struct client *clt) return; } - clt->clt_toread = TOREAD_HTTP_HEADER; inrd = server_read_http; slen = sizeof(clt->clt_sndbufsiz); @@ -1019,7 +1018,10 @@ server_error(struct bufferevent *bev, short error, void *arg) struct evbuffer *dst; if (error & EVBUFFER_TIMEOUT) { - server_abort_http(clt, 408, "timeout"); + if (clt->clt_toread != TOREAD_HTTP_INIT) + server_abort_http(clt, 408, "timeout"); + else + server_abort_http(clt, 0, "timeout"); return; } if (error & EVBUFFER_ERROR) { diff --git a/usr.sbin/httpd/server_http.c b/usr.sbin/httpd/server_http.c index 9306082edaf..c61e4128bf1 100644 --- a/usr.sbin/httpd/server_http.c +++ b/usr.sbin/httpd/server_http.c @@ -1,4 +1,4 @@ -/* $OpenBSD: server_http.c,v 1.123 2018/09/07 09:31:13 florian Exp $ */ +/* $OpenBSD: server_http.c,v 1.124 2018/10/01 19:24:09 benno Exp $ */ /* * Copyright (c) 2006 - 2018 Reyk Floeter <reyk@openbsd.org> @@ -88,6 +88,7 @@ server_httpdesc_init(struct client *clt) } RB_INIT(&desc->http_headers); clt->clt_descresp = desc; + clt->clt_toread = TOREAD_HTTP_INIT; return (0); } @@ -211,6 +212,10 @@ server_read_http(struct bufferevent *bev, void *arg) size = EVBUFFER_LENGTH(src); DPRINTF("%s: session %d: size %lu, to read %lld", __func__, clt->clt_id, size, clt->clt_toread); + + if (clt->clt_toread == TOREAD_HTTP_INIT) + clt->clt_toread = TOREAD_HTTP_HEADER; + if (!size) { clt->clt_toread = TOREAD_HTTP_HEADER; goto done; @@ -734,6 +739,7 @@ server_reset_http(struct client *clt) server_httpdesc_free(clt->clt_descresp); clt->clt_headerlen = 0; clt->clt_headersdone = 0; + clt->clt_toread = TOREAD_HTTP_INIT; clt->clt_done = 0; clt->clt_line = 0; clt->clt_chunk = 0; |