From fc2e09b66743a12ed2c1a885a21640d7274d6e99 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Julius=20H=C3=A4rtl?= <jus@bitgrid.net>
Date: Fri, 26 Feb 2021 11:12:20 +0100
Subject: [PATCH] Properly end iterating over the file once the target has been
 reached
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: Julius Härtl <jus@bitgrid.net>
---
 lib/private/Files/View.php | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/private/Files/View.php b/lib/private/Files/View.php
index 1bee09e3659..ed7d6c26318 100644
--- a/lib/private/Files/View.php
+++ b/lib/private/Files/View.php
@@ -456,7 +456,7 @@ class View {
 				// forward file handle via chunked fread because fseek seem to have failed
 
 				$end = $from + 1;
-				while (!feof($handle) && ftell($handle) < $end) {
+				while (!feof($handle) && ftell($handle) < $end && ftell($handle) !== $from) {
 					$len = $from - ftell($handle);
 					if ($len > $chunkSize) {
 						$len = $chunkSize;
-- 
GitLab