nghttpd: Limit request header buffer
This commit is contained in:
parent
28b643e531
commit
b0227d4051
|
@ -447,6 +447,7 @@ Stream::Stream(Http2Handler *handler, int32_t stream_id)
|
||||||
file_ent(nullptr),
|
file_ent(nullptr),
|
||||||
body_length(0),
|
body_length(0),
|
||||||
body_offset(0),
|
body_offset(0),
|
||||||
|
header_buffer_size(0),
|
||||||
stream_id(stream_id),
|
stream_id(stream_id),
|
||||||
echo_upload(false) {
|
echo_upload(false) {
|
||||||
auto config = handler->get_config();
|
auto config = handler->get_config();
|
||||||
|
@ -1389,6 +1390,13 @@ int on_header_callback(nghttp2_session *session, const nghttp2_frame *frame,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (stream->header_buffer_size + namelen + valuelen > 64_k) {
|
||||||
|
hd->submit_rst_stream(stream, NGHTTP2_INTERNAL_ERROR);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
stream->header_buffer_size += namelen + valuelen;
|
||||||
|
|
||||||
auto token = http2::lookup_token(name, namelen);
|
auto token = http2::lookup_token(name, namelen);
|
||||||
|
|
||||||
http2::index_header(stream->hdidx, token, stream->headers.size());
|
http2::index_header(stream->hdidx, token, stream->headers.size());
|
||||||
|
|
|
@ -119,6 +119,9 @@ struct Stream {
|
||||||
ev_timer wtimer;
|
ev_timer wtimer;
|
||||||
int64_t body_length;
|
int64_t body_length;
|
||||||
int64_t body_offset;
|
int64_t body_offset;
|
||||||
|
// Total amount of bytes (sum of name and value length) used in
|
||||||
|
// headers.
|
||||||
|
size_t header_buffer_size;
|
||||||
int32_t stream_id;
|
int32_t stream_id;
|
||||||
http2::HeaderIndex hdidx;
|
http2::HeaderIndex hdidx;
|
||||||
bool echo_upload;
|
bool echo_upload;
|
||||||
|
|
Loading…
Reference in New Issue