erofs-utils: lib: handle unexpected EOF in erofs_io_xcopy()
PATCH 1/1 erofs-utils: lib: handle unexpected EOF in erofs_io_xcopy()
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 <[email protected]>
--- lib/io.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
lib/io.c +6 -6
@@ -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 ;
Signature · 1 line
2.43.0