Re: [PATCH] Segmentation fault with INCLUDE_FS_TESTS and no -x option

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Nov 28, 2008 at 04:58:14PM +0200, Roy Peled wrote:
> The current implementation causes a segmentation fault if
> INCLUDE_FS_TESTS is defined, but the -x option is not specified.
> 
> The error is caused by the extract_dir variable being null.
> This simple patch assigns a dummy value to extract_dir,
> so that the filesystem tests can continue without error.

 See the patch below. I think it's better to use empty string rather
 than "/dummy", the output is:

$ ./fsck.cramfs -v  ../tests/input/cramfs-little.img
cramfs endianness is little
d 0755        16     0:0   /
d 0755        16     0:0   /dirA
d 0755        32     0:0   /dirA/dirB
f 0644       512     0:0   /dirA/dirB/a
f 0644     15360     0:0   /dirA/dirB/b
../tests/input/cramfs-little.img: OK


 BTW, the -x option seems as a nice feature, any idea why we don't use
 (compile) it?

    Karel

>From a6f72ab47ed750148a2373a0ffed5c9ec77c1dd5 Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@xxxxxxxxxx>
Date: Wed, 4 Feb 2009 23:36:39 +0100
Subject: [PATCH] fsck.cramfs: segfault with INCLUDE_FS_TESTS and no -x option

The current implementation causes a segmentation fault if
INCLUDE_FS_TESTS is defined, but the -x option is not specified.

The error is caused by the extract_dir variable being null.

Reported-by: Roy Peled <the.roy.peled@xxxxxxxxx>
Signed-off-by: Karel Zak <kzak@xxxxxxxxxx>
---
 disk-utils/fsck.cramfs.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/disk-utils/fsck.cramfs.c b/disk-utils/fsck.cramfs.c
index d388e78..649aef0 100644
--- a/disk-utils/fsck.cramfs.c
+++ b/disk-utils/fsck.cramfs.c
@@ -67,7 +67,7 @@ struct cramfs_super super;	/* just find the cramfs superblock once */
 static int cramfs_is_big_endian = 0;	/* source is big endian */
 static int opt_verbose = 0;	/* 1 = verbose (-v), 2+ = very verbose (-vv) */
 
-char *extract_dir = NULL;	/* extraction directory (-x) */
+char *extract_dir = "";	/* extraction directory (-x) */
 
 /* Exit codes used by fsck-type programs */
 #define FSCK_OK          0	/* No errors */
@@ -314,7 +314,8 @@ static void print_node(char type, struct cramfs_inode *i, char *name)
 	}
 
 	printf("%c %04o %s %5d:%-3d %s\n",
-	       type, i->mode & ~S_IFMT, info, i->uid, i->gid, name);
+	       type, i->mode & ~S_IFMT, info, i->uid, i->gid,
+	       !*name && type == 'd' ? "/" : name);
 }
 
 /*
-- 
1.6.0.6

--
To unsubscribe from this list: send the line "unsubscribe util-linux-ng" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux