From a6f72ab47ed750148a2373a0ffed5c9ec77c1dd5 Mon Sep 17 00:00:00 2001 From: Karel Zak 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 Signed-off-by: Karel Zak --- disk-utils/fsck.cramfs.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/disk-utils/fsck.cramfs.c b/disk-utils/fsck.cramfs.c index d388e787..649aef03 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); } /* -- 2.39.5