diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2025-08-16 14:47:52 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-08-16 14:47:52 -0700 |
| commit | 399bace2f20e64e4c10c014dc3b8e202a891c6e4 (patch) | |
| tree | a24ab1bbc42ca4d201bb43acd91f8e9815011fc4 /lib/std/http.zig | |
| parent | ef14c732455dc089b56aab7392584c4fa8bc2c2d (diff) | |
| parent | a0f9a5e78d1cf419e88c493f6f57e486df236e35 (diff) | |
| download | zig-399bace2f20e64e4c10c014dc3b8e202a891c6e4.tar.gz zig-399bace2f20e64e4c10c014dc3b8e202a891c6e4.zip | |
Merge pull request #24874 from ziglang/tls-client
std: more reliable HTTP and TLS networking
Diffstat (limited to 'lib/std/http.zig')
| -rw-r--r-- | lib/std/http.zig | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/std/http.zig b/lib/std/http.zig index 09251f6c69..640ac2e208 100644 --- a/lib/std/http.zig +++ b/lib/std/http.zig @@ -329,6 +329,7 @@ pub const Reader = struct { /// read from `in`. trailers: []const u8 = &.{}, body_err: ?BodyError = null, + max_head_len: usize, pub const RemainingChunkLen = enum(u64) { head = 0, @@ -387,10 +388,11 @@ pub const Reader = struct { pub fn receiveHead(reader: *Reader) HeadError![]const u8 { reader.trailers = &.{}; const in = reader.in; + const max_head_len = reader.max_head_len; var hp: HeadParser = .{}; var head_len: usize = 0; while (true) { - if (in.buffer.len - head_len == 0) return error.HttpHeadersOversize; + if (head_len >= max_head_len) return error.HttpHeadersOversize; const remaining = in.buffered()[head_len..]; if (remaining.len == 0) { in.fillMore() catch |err| switch (err) { |
