btrfs-progs: fix mkfs.btrfs segfault with --features option
authorHolger Hoffstätte <holger.hoffstaette@googlemail.com>
Sat, 26 Apr 2014 09:41:04 +0000 (09:41 +0000)
committerDavid Sterba <dsterba@suse.cz>
Fri, 2 May 2014 15:05:47 +0000 (17:05 +0200)
The mkfs.btrfs --features long option takes an argument but does not
declare it. Consequently getopt does not allocate an argument, which
makes an unconditional strdup() crash during options parsing.
Fix by declaring the argument in the options alias array.

Signed-off-by: Holger Hoffstätte <holger.hoffstaette@googlemail.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
mkfs.c

diff --git a/mkfs.c b/mkfs.c
index 4f5ee07..16e9222 100644 (file)
--- a/mkfs.c
+++ b/mkfs.c
@@ -350,7 +350,7 @@ static struct option long_options[] = {
        { "version", 0, NULL, 'V' },
        { "rootdir", 1, NULL, 'r' },
        { "nodiscard", 0, NULL, 'K' },
-       { "features", 0, NULL, 'O' },
+       { "features", 1, NULL, 'O' },
        { NULL, 0, NULL, 0}
 };