Skip to content

Commit b646741

Browse files
committed
bail after too many failed reads
Submitted By: icing git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1916771 13f79535-47bb-0310-9956-ffa450edef68
1 parent e98c400 commit b646741

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

modules/http2/h2_session.c

+7-3
Original file line numberDiff line numberDiff line change
@@ -319,9 +319,13 @@ static int on_header_cb(nghttp2_session *ngh2, const nghttp2_frame *frame,
319319

320320
status = h2_stream_add_header(stream, (const char *)name, namelen,
321321
(const char *)value, valuelen);
322-
if (status != APR_SUCCESS
323-
&& (!stream->rtmp
324-
|| stream->rtmp->http_status == H2_HTTP_STATUS_UNSET)) {
322+
if (status != APR_SUCCESS &&
323+
(!stream->rtmp ||
324+
stream->rtmp->http_status == H2_HTTP_STATUS_UNSET ||
325+
/* We accept a certain amount of failures in order to reply
326+
* with an informative HTTP error response like 413. But if the
327+
* client is too wrong, we fail the request a RESET of the stream */
328+
stream->request_headers_failed > 100)) {
325329
return NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE;
326330
}
327331
return 0;

modules/http2/h2_stream.c

+1
Original file line numberDiff line numberDiff line change
@@ -813,6 +813,7 @@ apr_status_t h2_stream_add_header(h2_stream *stream,
813813

814814
cleanup:
815815
if (error) {
816+
++stream->request_headers_failed;
816817
set_error_response(stream, error);
817818
return APR_EINVAL;
818819
}

modules/http2/h2_stream.h

+1
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ struct h2_stream {
9191
struct h2_request *rtmp; /* request being assembled */
9292
apr_table_t *trailers_in; /* optional, incoming trailers */
9393
int request_headers_added; /* number of request headers added */
94+
int request_headers_failed; /* number of request headers failed to add */
9495

9596
#if AP_HAS_RESPONSE_BUCKETS
9697
ap_bucket_response *response; /* the final, non-interim response or NULL */

0 commit comments

Comments
 (0)