Skip to contentSkip to conversation

erofs-utils: lib: fix two integer handling issues

PATCH New Gao Xiang 1 participant 1 message Jun 17, 2025 Library code

lore
Share & tools
lore

Gao Xiang

author
#0 lore raw

PATCH 1/1 erofs-utils: lib: fix two integer handling issues

Coverity-id: 554931
Coverity-id: 555116

---
 lib/super.c | 5 +++++
 lib/vmdk.c  | 2 +-
 2 files changed, 6 insertions(+), 1 deletion(-)
lib/super.c +5 -0
index beab74e..a300a5f 100644
@@ -327,6 +327,11 @@ int erofs_write_device_table(struct erofs_sb_info *sbi)
 		return -EINVAL;
 
 	pos = erofs_btell(bh, false);
+	if (pos == NULL_ADDR_UL) {
+		DBG_BUGON(1);
+		return -EINVAL;
+	}
+
 	i = 0;
 	do {
 		struct erofs_deviceslot dis = {
lib/vmdk.c +1 -1
index 06d4a49..8080c51 100644
@@ -60,7 +60,7 @@ int erofs_dump_vmdk_desc(FILE *f, struct erofs_sb_info *sbi)
 		const char *name = sbi->devs[i].src_path ?:
 				(const char *)sbi->devs[i].tag;
 
-		sectors = sbi->devs[i].blocks << (sbi->blkszbits - 9);
+		sectors = (u64)sbi->devs[i].blocks << (sbi->blkszbits - 9);
 		ret = erofs_vmdk_desc_add_extent(f, sectors, name, 0);
 		if (ret)
 			return ret;
Signature · 1 line
2.43.5