Skip to contentSkip to conversation

erofs-utils: lib: fix off-by-one issue with invalid device ID

PATCH New Gao Xiang 1 participant 1 message Sep 17, 2024 Library code

lore
Share & tools
lore

Gao Xiang

author
#0 lore raw

PATCH 1/1 erofs-utils: lib: fix off-by-one issue with invalid device ID

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")
---
 lib/io.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/io.c +1 -1
index b101c07..dacf8dc 100644
@@ -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;
 		}
Signature · 1 line
2.43.5