[PATCH 1/1] httpd: fix offset for sendfile

Maxim Storchak m.storchak at gmail.com
Tue Dec 29 15:29:05 UTC 2020


If the Range: header is not present it the request,
the offset passed to sendfile is wrong,
and httpd falls back to the read-write loop.

Signed-off-by: Maxim Storchak <m.storchak at gmail.com>
---
 networking/httpd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/networking/httpd.c b/networking/httpd.c
index 4346141ee..cc9828e78 100644
--- a/networking/httpd.c
+++ b/networking/httpd.c
@@ -1871,7 +1871,7 @@ static NOINLINE void send_file_and_exit(const char *url, int what)
 		send_headers(HTTP_OK);
 #if ENABLE_FEATURE_USE_SENDFILE
 	{
-		off_t offset = range_start;
+		off_t offset = (range_start==-1)?0:range_start;
 		while (1) {
 			/* sz is rounded down to 64k */
 			ssize_t sz = MAXINT(ssize_t) - 0xffff;
-- 
2.28.0



More information about the busybox mailing list