From 10c7ab0889e7f7a1a3a23504402799c371b35544 Mon Sep 17 00:00:00 2001 From: JustAnotherArchivist Date: Tue, 10 Jan 2023 18:00:40 +0000 Subject: [PATCH] Fix off-by-one error for non-chunked responses --- http-response-bodies.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/http-response-bodies.c b/http-response-bodies.c index ad0691c..10c781e 100644 --- a/http-response-bodies.c +++ b/http-response-bodies.c @@ -205,7 +205,7 @@ checkstate: return 1; } } else if (state == STATE_BODY || state == STATE_CHUNK_CONTENTS) { - if (length + 2 - bytes_read > n) { + if (length + (state == STATE_BODY ? 1 : 2) - bytes_read > n) { // Only got part of the body DEBUG_PRINTF("Partial body\n"); DEBUG_PRINTF("Copying %zu bytes to stdout\n", n);