diff options
author | Eric Andersen <andersen@codepoet.org> | 2004-07-30 23:52:08 +0000 |
---|---|---|
committer | Eric Andersen <andersen@codepoet.org> | 2004-07-30 23:52:08 +0000 |
commit | 67776bef59096ff09cea39cb7c6e382b7c4f4a60 (patch) | |
tree | 0bd2be3d7957fba80b8aa9c82d0cb716cee90bad /editors/awk.c | |
parent | cbcdbc41ffab413767569891b58526b4d1066627 (diff) | |
download | busybox-w32-67776bef59096ff09cea39cb7c6e382b7c4f4a60.tar.gz busybox-w32-67776bef59096ff09cea39cb7c6e382b7c4f4a60.tar.bz2 busybox-w32-67776bef59096ff09cea39cb7c6e382b7c4f4a60.zip |
Simon Poole reports that awk segfaults when environment variables
with no value exist, i.e.
$ export BOB=''
% ./busybox awk
Segmentation fault
This patch teaches awk to not blow chunks on empty env variables.
-Erik
Diffstat (limited to 'editors/awk.c')
-rw-r--r-- | editors/awk.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/editors/awk.c b/editors/awk.c index af8958925..c0e1a71fe 100644 --- a/editors/awk.c +++ b/editors/awk.c | |||
@@ -2670,8 +2670,12 @@ extern int awk_main(int argc, char **argv) { | |||
2670 | for (envp=environ; *envp; envp++) { | 2670 | for (envp=environ; *envp; envp++) { |
2671 | s = bb_xstrdup(*envp); | 2671 | s = bb_xstrdup(*envp); |
2672 | s1 = strchr(s, '='); | 2672 | s1 = strchr(s, '='); |
2673 | if (!s1) { | ||
2674 | goto keep_going; | ||
2675 | } | ||
2673 | *(s1++) = '\0'; | 2676 | *(s1++) = '\0'; |
2674 | setvar_u(findvar(iamarray(V[ENVIRON]), s), s1); | 2677 | setvar_u(findvar(iamarray(V[ENVIRON]), s), s1); |
2678 | keep_going: | ||
2675 | free(s); | 2679 | free(s); |
2676 | } | 2680 | } |
2677 | 2681 | ||