Whamcloud - gitweb
debugfs: fix crash in ea_set argument handling
authorDarrick J. Wong <darrick.wong@oracle.com>
Tue, 27 Jan 2015 15:58:17 +0000 (10:58 -0500)
committerTheodore Ts'o <tytso@mit.edu>
Tue, 27 Jan 2015 15:58:17 +0000 (10:58 -0500)
Fix an incorrect check in ea_set that would crash debugfs if someone
runs 'ea_set / foo.bar' (i.e. with no value argument)

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
debugfs/xattrs.c

index a80fd0b..e71bc15 100644 (file)
@@ -202,7 +202,7 @@ void do_set_xattr(int argc, char **argv)
                }
        }
 
-       if (optind != argc - 2 && optind != argc - 3) {
+       if (!(fp && optind == argc - 2) && !(!fp && optind == argc - 3)) {
                printf("%s: Usage: %s <file> <attr> [-f infile | value>]\n",
                       argv[0], argv[0]);
                goto out2;