summaryrefslogtreecommitdiff
path: root/e2fsprogs
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2021-06-23 18:57:00 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2021-06-23 18:57:00 +0200
commit5709b51a75c6fe2cf6afcb2f5dcb9d227899f351 (patch)
tree5c2a05752382ade0d97f481ab834ee352a2dbae4 /e2fsprogs
parent85a5bc91487ae1b4014f2ee6595873c8330fa7a7 (diff)
downloadbusybox-5709b51a75c6fe2cf6afcb2f5dcb9d227899f351.tar.gz
chattr: fix "chattr =ae -R FILE"
-R is not an "unset these flags" argument, thus no conflict with "=". function old new delta .rodata 103684 103686 +2 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'e2fsprogs')
-rw-r--r--e2fsprogs/chattr.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/e2fsprogs/chattr.c b/e2fsprogs/chattr.c
index b424e797b..1b12c9f37 100644
--- a/e2fsprogs/chattr.c
+++ b/e2fsprogs/chattr.c
@@ -85,7 +85,9 @@ static char** decode_arg(char **argv, struct globals *gp)
fl = &gp->af;
if (opt == '-') {
- gp->flags |= OPT_REM;
+ /* gp->flags |= OPT_REM; - WRONG, it can be an option */
+ /* testcase: chattr =ae -R FILE should not complain "= is incompatible with - and +" */
+ /* (and should not read flags, with =FLAGS they can be just set directly) */
fl = &gp->rf;
} else if (opt == '+') {
gp->flags |= OPT_ADD;
@@ -115,7 +117,7 @@ static char** decode_arg(char **argv, struct globals *gp)
if (*arg == 'v') {
if (!*++argv)
bb_show_usage();
- gp->version = xatoul(*argv);
+ gp->version = xatou(*argv);
gp->flags |= OPT_SET_VER;
continue;
}
@@ -127,8 +129,9 @@ static char** decode_arg(char **argv, struct globals *gp)
continue;
}
/* not a known option, try as an attribute */
+ gp->flags |= OPT_REM;
}
- *fl |= get_flag(*arg);
+ *fl |= get_flag(*arg); /* aborts on bad flag letter */
}
return argv;
@@ -241,7 +244,7 @@ int chattr_main(int argc UNUSED_PARAM, char **argv)
if (g.rf & g.af)
bb_simple_error_msg_and_die("can't set and unset a flag");
if (!g.flags)
- bb_simple_error_msg_and_die("must use '-v', =, - or +");
+ bb_simple_error_msg_and_die("must use -v, -p, =, - or +");
/* now run chattr on all the files passed to us */
do change_attributes(*argv, &g); while (*++argv);