public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
* [PATCH] mkfs.jffs2: fix segfault when parsing dev table
@ 2024-09-27 21:14 Rosen Penev
  2024-09-29  2:12 ` Zhihao Cheng
  0 siblings, 1 reply; 2+ messages in thread
From: Rosen Penev @ 2024-09-27 21:14 UTC (permalink / raw)
  To: linux-mtd

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

Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
 jffsX-utils/mkfs.jffs2.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/jffsX-utils/mkfs.jffs2.c b/jffsX-utils/mkfs.jffs2.c
index b9dd96b..63dac1c 100644
--- a/jffsX-utils/mkfs.jffs2.c
+++ b/jffsX-utils/mkfs.jffs2.c
@@ -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;
 	}
-- 
2.46.1


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

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-09-29  2:13 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-27 21:14 [PATCH] mkfs.jffs2: fix segfault when parsing dev table Rosen Penev
2024-09-29  2:12 ` Zhihao Cheng

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox