[tools] fix segfault when using the maxlen argument (#4359)
[openwrt.git] / package / busybox / patches / 250-ash_export-n.patch
1 --- a/shell/ash.c
2 +++ b/shell/ash.c
3 @@ -12159,8 +12159,17 @@ exportcmd(int argc UNUSED_PARAM, char **
4 const char *p;
5 char **aptr;
6 int flag = argv[0][0] == 'r' ? VREADONLY : VEXPORT;
7 + int mask = ~0;
8 + int nopt;
9 + while ((nopt = nextopt("np"))) {
10 + if (nopt == 'n') {
11 + mask = ~flag;
12 + } else { /* p */
13 + break;
14 + }
15 + }
16
17 - if (nextopt("p") != 'p') {
18 + if (nopt != 'p') {
19 aptr = argptr;
20 name = *aptr;
21 if (name) {
22 @@ -12172,10 +12181,12 @@ exportcmd(int argc UNUSED_PARAM, char **
23 vp = *findvar(hashvar(name), name);
24 if (vp) {
25 vp->flags |= flag;
26 + vp->flags &= mask;
27 continue;
28 }
29 }
30 setvar(name, p, flag);
31 + setvar(name, p, flag & mask);
32 } while ((name = *++aptr) != NULL);
33 return 0;
34 }
This page took 0.044044 seconds and 5 git commands to generate.