From 9c25581d6fb20488d13e4b17f6f62212408ad04c Mon Sep 17 00:00:00 2001 From: Glenn Strauss Date: Sun, 11 Oct 2020 12:23:21 -0400 Subject: [PATCH] [core] alloc optim reading file, sending chunked avoid potential double-copy due to not enough space for final '\0' in http_chunk_append_read_fd_range() if read size is exactly multiple of 8k and sending chunked response --- src/http_chunk.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/http_chunk.c b/src/http_chunk.c index fb76a99e..07bde8b5 100644 --- a/src/http_chunk.c +++ b/src/http_chunk.c @@ -77,7 +77,7 @@ static int http_chunk_append_read_fd_range(request_st * const r, const buffer * http_chunk_len_append(cq, (uintmax_t)len); if (0 != offset && -1 == lseek(fd, offset, SEEK_SET)) return -1; - buffer * const b = chunkqueue_append_buffer_open_sz(cq, len+2); + buffer * const b = chunkqueue_append_buffer_open_sz(cq, len+2+1); ssize_t rd; offset = 0; do {