[PATCH] erofs-utils: lib: handle short reads in inode fingerprint
Vansh Choudhary
ch at vnsh.in
Tue Apr 21 04:23:18 AEST 2026
Treat a zero-byte erofs_io_pread() return as I/O failure when
hashing inode->i_size bytes for the inode fingerprint.
Without that, pread() returning 0 on EOF (source shorter than
i_size, e.g. truncated between stat() and fingerprinting) leaves
"remaining" unchanged and mkfs.erofs spins forever.
Fixes: 5e7cdf7593ae ("erofs-utils: mkfs: add `--xattr-inode-digest` option")
Signed-off-by: Vansh Choudhary <ch at vnsh.in>
---
lib/inode.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/lib/inode.c b/lib/inode.c
index b3e5f62..bac21dc 100644
--- a/lib/inode.c
+++ b/lib/inode.c
@@ -2005,6 +2005,8 @@ static int erofs_set_inode_fingerprint(struct erofs_inode *inode, int fd,
min_t(u64, remaining, sizeof(buf)), pos);
if (ret < 0)
return ret;
+ if (!ret)
+ return -EIO;
if (ret > 0)
erofs_sha256_process(&md, buf, ret);
remaining -= ret;
--
2.43.0
More information about the Linux-erofs
mailing list