From 7a4269329fa05411b477b540beebf18af90e9b42 Mon Sep 17 00:00:00 2001
From: Rob Walker <rwalker@codeaurora.org>
Date: Tue, 3 Apr 2012 08:09:28 +0200
Subject: [PATCH] httpd: emit correct content length on range requests past the
 end. Closes 4952

Signed-off-by: Rob Walker <rwalker@codeaurora.org>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
---
 networking/httpd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/networking/httpd.c b/networking/httpd.c
index f233cb0ba..fb6ecbf70 100644
--- a/networking/httpd.c
+++ b/networking/httpd.c
@@ -1594,7 +1594,7 @@ static NOINLINE void send_file_and_exit(const char *url, int what)
 	}
 	range_len = MAXINT(off_t);
 	if (range_start >= 0) {
-		if (!range_end) {
+		if (!range_end || range_end > file_size - 1) {
 			range_end = file_size - 1;
 		}
 		if (range_end < range_start