aboutsummaryrefslogtreecommitdiff
path: root/shell/hush.c
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2017-07-18 01:40:01 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2017-07-18 01:40:01 +0200
commit38ef39a1abd46ca390b0259ebd0b35e9ea9ccb68 (patch)
tree7c2f7de98cd1a7b467be6529eff98c23b999af17 /shell/hush.c
parent3bab36b18baa0dc254445828f492051450a38d41 (diff)
downloadbusybox-w32-38ef39a1abd46ca390b0259ebd0b35e9ea9ccb68.tar.gz
busybox-w32-38ef39a1abd46ca390b0259ebd0b35e9ea9ccb68.tar.bz2
busybox-w32-38ef39a1abd46ca390b0259ebd0b35e9ea9ccb68.zip
hush: add readonly testcase, fix fallout
function old new delta helper_export_local 185 214 +29 run_pipe 1549 1560 +11 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 2/0 up/down: 40/0) Total: 40 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'shell/hush.c')
-rw-r--r--shell/hush.c26
1 files changed, 17 insertions, 9 deletions
diff --git a/shell/hush.c b/shell/hush.c
index 7771172b6..eab1284f6 100644
--- a/shell/hush.c
+++ b/shell/hush.c
@@ -7767,10 +7767,10 @@ static NOINLINE int run_pipe(struct pipe *pi)
7767 if (new_env) { 7767 if (new_env) {
7768 argv = new_env; 7768 argv = new_env;
7769 while (*argv) { 7769 while (*argv) {
7770 set_local_var(*argv, /*flag:*/ 0); 7770 if (set_local_var(*argv, /*flag:*/ 0)) {
7771 /* Do we need to flag set_local_var() errors? 7771 /* assignment to readonly var / putenv error? */
7772 * "assignment to readonly var" and "putenv error" 7772 rcode = 1;
7773 */ 7773 }
7774 argv++; 7774 argv++;
7775 } 7775 }
7776 } 7776 }
@@ -7795,10 +7795,10 @@ static NOINLINE int run_pipe(struct pipe *pi)
7795 fprintf(stderr, " %s", p); 7795 fprintf(stderr, " %s", p);
7796 debug_printf_exec("set shell var:'%s'->'%s'\n", 7796 debug_printf_exec("set shell var:'%s'->'%s'\n",
7797 *argv, p); 7797 *argv, p);
7798 set_local_var(p, /*flag:*/ 0); 7798 if (set_local_var(p, /*flag:*/ 0)) {
7799 /* Do we need to flag set_local_var() errors? 7799 /* assignment to readonly var / putenv error? */
7800 * "assignment to readonly var" and "putenv error" 7800 rcode = 1;
7801 */ 7801 }
7802 argv++; 7802 argv++;
7803 } 7803 }
7804 if (G_x_mode) 7804 if (G_x_mode)
@@ -9336,6 +9336,13 @@ static int helper_export_local(char **argv, unsigned flags)
9336 continue; 9336 continue;
9337 } 9337 }
9338 } 9338 }
9339 if (flags & SETFLAG_MAKE_RO) {
9340 /* readonly NAME (without =VALUE) */
9341 if (var) {
9342 var->flg_read_only = 1;
9343 continue;
9344 }
9345 }
9339# if ENABLE_HUSH_LOCAL 9346# if ENABLE_HUSH_LOCAL
9340 /* Is this "local" bltin? */ 9347 /* Is this "local" bltin? */
9341 if (!(flags & (SETFLAG_EXPORT|SETFLAG_UNEXPORT|SETFLAG_MAKE_RO))) { 9348 if (!(flags & (SETFLAG_EXPORT|SETFLAG_UNEXPORT|SETFLAG_MAKE_RO))) {
@@ -9364,7 +9371,8 @@ static int helper_export_local(char **argv, unsigned flags)
9364 /* (Un)exporting/making local NAME=VALUE */ 9371 /* (Un)exporting/making local NAME=VALUE */
9365 name = xstrdup(name); 9372 name = xstrdup(name);
9366 } 9373 }
9367 set_local_var(name, flags); 9374 if (set_local_var(name, flags))
9375 return EXIT_FAILURE;
9368 } while (*++argv); 9376 } while (*++argv);
9369 return EXIT_SUCCESS; 9377 return EXIT_SUCCESS;
9370} 9378}