From 5ac067ad8c3345586fc7aefb888867a7ea8353be Mon Sep 17 00:00:00 2001 From: countingpine Date: Thu, 16 Mar 2023 17:48:42 +0000 Subject: [PATCH] Truncate range requests that go past the end of the file If the range end was too high, the function would try (and fail) to return the full range asked for. Fixes Issue #7. --- smartReadFile.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/smartReadFile.php b/smartReadFile.php index 3e3fe3e..9a10621 100644 --- a/smartReadFile.php +++ b/smartReadFile.php @@ -40,7 +40,7 @@ function smartReadFile($location, $filename, $mimeType = 'application/octet-stre $begin = intval($matches[1]); if (!empty($matches[2])) { - $end = intval($matches[2]); + $end = min($end, intval($matches[2])); } } }