Skip to contentSkip to conversation

mkfs.jffs2: fix segfault when parsing dev table

PATCH Superseded Rosen Penev 2 participants 2 messages Sep 27, 2024 – Sep 29, 2024 Memory technology devices (MTD)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mkfs.jffs2: fix segfault when parsing dev table

Make sure that all 10 items are parsed correctly. One issue otherwise is a null pointer dereference when the first item is not found.

---
 jffsX-utils/mkfs.jffs2.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
jffsX-utils/mkfs.jffs2.c +1 -1
index b9dd96b..63dac1c 100644
@@ -428,7 +428,7 @@ static int interpret_table_entry(struct filesystem_entry *root, char *line)
 
 	if (sscanf (line, "%" SCANF_PREFIX "s %c %lo %lu %lu %lu %lu %lu %lu %lu",
 				SCANF_STRING(name), &type, &mode, &uid, &gid, &major, &minor,
-				&start, &increment, &count) < 0)
+				&start, &increment, &count) < 10)
 	{
 		return 1;
 	}
Signature · 6 lines
2.46.1


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
#1 lore raw
Quoted 13 lines · Rosen Penev

Make sure that all 10 items are parsed correctly. One issue otherwise is a null pointer dereference when the first item is not found.

---
  jffsX-utils/mkfs.jffs2.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
jffsX-utils/mkfs.jffs2.c +0 -0
index b9dd96b..63dac1c 100644

jffsX-utils/mkfs.jffs2.c static int interpret_table_entry(struct filesystem_entry *root, char *line) · line 431

Quoted 5 lines
jffsX-utils/mkfs.jffs2.c +1 -1
@@ -428,7 +428,7 @@ static int interpret_table_entry(struct filesystem_entry *root, char *line)
 
  	if (sscanf (line, "%" SCANF_PREFIX "s %c %lo %lu %lu %lu %lu %lu %lu %lu",
  				SCANF_STRING(name), &type, &mode, &uid, &gid, &major, &minor,
-				&start, &increment, &count) < 0)
+				&start, &increment, &count) < 10)

The last 8 variables are initialized earlier, how about changing like following?

				&start, &increment, &count) < 2)

jffsX-utils/mkfs.jffs2.c static int interpret_table_entry(struct filesystem_entry *root, char *line) · line 434

Quoted 4 lines
jffsX-utils/mkfs.jffs2.c +0 -0
  	{
  		return 1;
  	}

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/