From fc8a1d6ab51e56fc32742c73fcc02e23705bb23b Mon Sep 17 00:00:00 2001 From: Gao Xiang Date: Mon, 17 Feb 2025 10:49:28 +0800 Subject: [PATCH] erofs-utils: fix potential buffer overrun in __erofs_io_write() .. due to short write, but it's almost impossible for most fses. Coverity-id: 541575 Signed-off-by: Gao Xiang Link: https://lore.kernel.org/r/20250217024929.66658-1-hsiangkao@linux.alibaba.com --- lib/io.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/io.c b/lib/io.c index b6eb22a..5c3d263 100644 --- a/lib/io.c +++ b/lib/io.c @@ -31,7 +31,7 @@ ssize_t __erofs_io_write(int fd, const void *buf, size_t len) ssize_t ret, written = 0; do { - ret = write(fd, buf, len); + ret = write(fd, buf, len - written); if (ret <= 0) { if (!ret) break; -- 2.34.1