Skip to content

Commit 1c82ccc

Browse files
committed
Merge branch 'max-header-lines'
2 parents 4f4d719 + ced0bf9 commit 1c82ccc

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

doc/modules/http.h1_stream.md

+5
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ The gzip transfer encoding is supported transparently.
99
See [`stream.connection`](#stream.connection)
1010

1111

12+
### `h1_stream.max_header_lines` <!-- --> {#http.h1_stream.max_header_lines}
13+
14+
The maximum number of header lines to read. Default is `100`.
15+
16+
1217
### `h1_stream:checktls()` <!-- --> {#http.h1_stream:checktls}
1318

1419
See [`stream:checktls()`](#stream:checktls)

http/h1_stream.lua

+4
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ end
4646

4747
local stream_methods = {
4848
use_zlib = has_zlib;
49+
max_header_lines = 100;
4950
}
5051
for k,v in pairs(stream_common.methods) do
5152
stream_methods[k] = v
@@ -321,6 +322,9 @@ function stream_methods:read_headers(timeout)
321322

322323
-- Use while loop for lua 5.1 compatibility
323324
while true do
325+
if headers:len() >= self.max_header_lines then
326+
return nil, ce.strerror(ce.E2BIG), ce.E2BIG
327+
end
324328
local k, v, errno = self.connection:read_header(0)
325329
if k == nil then
326330
if v ~= nil then

0 commit comments

Comments
 (0)