From bd43cb7d042097a52a8b6419a08409e7a1b7bfff Mon Sep 17 00:00:00 2001 From: Josh Date: Mon, 13 Oct 2025 18:26:48 -0400 Subject: [PATCH] fix(files): decrement quota by actual bytes written in stream_write The quota is now decremented by the actual number of bytes written ($written) rather than the intended size. This ensures quota tracking stays accurate even if fwrite writes fewer (or more - i.e. from underlying buffering/etc) bytes than requested. Signed-off-by: Josh --- lib/private/Files/Stream/Quota.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/private/Files/Stream/Quota.php b/lib/private/Files/Stream/Quota.php index cc737910fd8..3c7e09c633b 100644 --- a/lib/private/Files/Stream/Quota.php +++ b/lib/private/Files/Stream/Quota.php @@ -78,7 +78,10 @@ class Quota extends Wrapper { $data = substr($data, 0, $this->limit); $size = $this->limit; } - $this->limit -= $size; - return fwrite($this->source, $data); + $written = fwrite($this->source, $data); + // Decrement quota by the actual number of bytes written ($written), + // not the intended size + $this->limit -= $written; + return $written; } }