aboutsummaryrefslogtreecommitdiff
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
parent85a5bc91487ae1b4014f2ee6595873c8330fa7a7 (diff)
downloadbusybox-w32-5709b51a75c6fe2cf6afcb2f5dcb9d227899f351.tar.gz
busybox-w32-5709b51a75c6fe2cf6afcb2f5dcb9d227899f351.tar.bz2
busybox-w32-5709b51a75c6fe2cf6afcb2f5dcb9d227899f351.zip
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>
-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)
85 85
86 fl = &gp->af; 86 fl = &gp->af;
87 if (opt == '-') { 87 if (opt == '-') {
88 gp->flags |= OPT_REM; 88 /* gp->flags |= OPT_REM; - WRONG, it can be an option */
89 /* testcase: chattr =ae -R FILE should not complain "= is incompatible with - and +" */
90 /* (and should not read flags, with =FLAGS they can be just set directly) */
89 fl = &gp->rf; 91 fl = &gp->rf;
90 } else if (opt == '+') { 92 } else if (opt == '+') {
91 gp->flags |= OPT_ADD; 93 gp->flags |= OPT_ADD;
@@ -115,7 +117,7 @@ static char** decode_arg(char **argv, struct globals *gp)
115 if (*arg == 'v') { 117 if (*arg == 'v') {
116 if (!*++argv) 118 if (!*++argv)
117 bb_show_usage(); 119 bb_show_usage();
118 gp->version = xatoul(*argv); 120 gp->version = xatou(*argv);
119 gp->flags |= OPT_SET_VER; 121 gp->flags |= OPT_SET_VER;
120 continue; 122 continue;
121 } 123 }
@@ -127,8 +129,9 @@ static char** decode_arg(char **argv, struct globals *gp)
127 continue; 129 continue;
128 } 130 }
129 /* not a known option, try as an attribute */ 131 /* not a known option, try as an attribute */
132 gp->flags |= OPT_REM;
130 } 133 }
131 *fl |= get_flag(*arg); 134 *fl |= get_flag(*arg); /* aborts on bad flag letter */
132 } 135 }
133 136
134 return argv; 137 return argv;
@@ -241,7 +244,7 @@ int chattr_main(int argc UNUSED_PARAM, char **argv)
241 if (g.rf & g.af) 244 if (g.rf & g.af)
242 bb_simple_error_msg_and_die("can't set and unset a flag"); 245 bb_simple_error_msg_and_die("can't set and unset a flag");
243 if (!g.flags) 246 if (!g.flags)
244 bb_simple_error_msg_and_die("must use '-v', =, - or +"); 247 bb_simple_error_msg_and_die("must use -v, -p, =, - or +");
245 248
246 /* now run chattr on all the files passed to us */ 249 /* now run chattr on all the files passed to us */
247 do change_attributes(*argv, &g); while (*++argv); 250 do change_attributes(*argv, &g); while (*++argv);