From b534e70cf5529378a1ed994492641ec0330554eb Mon Sep 17 00:00:00 2001 From: David Woodhouse Date: Sat, 13 Oct 2007 11:35:58 +0100 Subject: [JFFS2] Handle dirents on the flash with embedded zero bytes in names. In three places: summary scan, normal scan, REF_PRISTINE GC. Just truncate at the NUL, since that was the correct thing to do in the only case where this (inexplicable) breakage has been seen. Signed-off-by: David Woodhouse --- fs/jffs2/gc.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'fs/jffs2/gc.c') diff --git a/fs/jffs2/gc.c b/fs/jffs2/gc.c index 95be264fe9b..f25e485ed87 100644 --- a/fs/jffs2/gc.c +++ b/fs/jffs2/gc.c @@ -608,10 +608,15 @@ static int jffs2_garbage_collect_pristine(struct jffs2_sb_info *c, goto bail; } + if (strnlen(node->d.name, node->d.nsize) != node->d.nsize) { + printk(KERN_WARNING "Name in dirent node at 0x%08x contains zeroes\n", ref_offset(raw)); + goto bail; + } + if (node->d.nsize) { crc = crc32(0, node->d.name, node->d.nsize); if (je32_to_cpu(node->d.name_crc) != crc) { - printk(KERN_WARNING "Name CRC failed on REF_PRISTINE dirent ode at 0x%08x: Read 0x%08x, calculated 0x%08x\n", + printk(KERN_WARNING "Name CRC failed on REF_PRISTINE dirent node at 0x%08x: Read 0x%08x, calculated 0x%08x\n", ref_offset(raw), je32_to_cpu(node->d.name_crc), crc); goto bail; } -- cgit v1.2.3