[PATCH] erofs-utils: lib: fix off-by-one issue with invalid device ID
Gao Xiang
hsiangkao at linux.alibaba.com
Tue Sep 17 19:11:15 AEST 2024
The device ID should be no less than `1 + number of blobs`. In other
words, it should be greater than `number of blobs`.
Fixes: 89dfe997c2ee ("erofs-utils: lib: fix global-buffer-overflow due to invalid device")
Signed-off-by: Gao Xiang <hsiangkao at 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 b101c07..dacf8dc 100644
--- a/lib/io.c
+++ b/lib/io.c
@@ -342,7 +342,7 @@ ssize_t erofs_dev_read(struct erofs_sb_info *sbi, int device_id,
ssize_t read;
if (device_id) {
- if (device_id >= sbi->nblobs) {
+ if (device_id > sbi->nblobs) {
erofs_err("invalid device id %d", device_id);
return -EIO;
}
--
2.43.5
More information about the Linux-erofs
mailing list