[PATCH] erofs-utils: lib: handle unexpected EOF in erofs_io_xcopy()
Vansh Choudhary
ch at vnsh.in
Fri Apr 10 03:54:25 AEST 2026
Treat a zero-length read from erofs_io_read() as an I/O failure when
erofs_io_xcopy() still has data left to copy.
Without that, the copy loop makes no forward progress after an early
EOF and can spin indefinitely.
Signed-off-by: Vansh Choudhary <ch at vnsh.in>
---
lib/io.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/lib/io.c b/lib/io.c
index 0c5eb2c..80b7639 100644
--- a/lib/io.c
+++ b/lib/io.c
@@ -667,12 +667,12 @@ int erofs_io_xcopy(struct erofs_vfile *vout, off_t pos,
ret = erofs_io_read(vin, buf, ret);
if (ret < 0)
return ret;
- if (ret > 0) {
- ret = erofs_io_pwrite(vout, buf, pos, ret);
- if (ret < 0)
- return ret;
- pos += ret;
- }
+ if (!ret)
+ return -EIO;
+ ret = erofs_io_pwrite(vout, buf, pos, ret);
+ if (ret < 0)
+ return ret;
+ pos += ret;
len -= ret;
} while (len);
return 0;
--
2.43.0
More information about the Linux-erofs
mailing list