Skip to contentSkip to conversation

mkfs.jffs2.c: Fix issue with crashing when using lzo compression

PATCH New Jussi Hakala 1 participant 1 message Apr 15, 2008 Memory technology devices (MTD)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mkfs.jffs2.c: Fix issue with crashing when using lzo compression

Calling jffs2_compressors_init() before page_size results in invalid compression buffer, which in turn leads to segmentation fault when lzo compression is used, for example:

mkfs.jffs2 -r /path-to/mtd-test -o /tmp/mtd-test.jffs2 -e 128KiB -l -n -X lzo -x zlib

Thanks to Siarhei Siamashka <siarhei dot siamashka at nokia dot com> for the patch.

mtd-utils-0.0~200802271600/mkfs.jffs2.c renamed from mtd-utils-0.0~200802271600.orig/mkfs.jffs2.c +2 -2
diff -Naur main.d/mtd-utils-0.0~200802271600.orig/mkfs.jffs2.c main.d/mtd-utils-0.0~200802271600/mkfs.jffs2.c
@@ -1662,14 +1662,14 @@
 	int compr_prior  = -1;
 	int warn_page_size = 0;
 
-	jffs2_compressors_init();
-
 	page_size = sysconf(_SC_PAGESIZE);
 	if (page_size < 0) /* System doesn't know so ... */
 		page_size = 4096; /* ... we make an educated guess */
 	if (page_size != 4096)
 		warn_page_size = 1; /* warn user if page size not 4096 */
 
+	jffs2_compressors_init();
+
 	while ((opt = getopt_long(argc, argv,
 					"D:d:r:s:o:qUPfh?vVe:lbp::nc:m:x:X:Lty:i:", long_options, &c)) >= 0)
 	{