diff options
author | Ron Yorston <rmy@pobox.com> | 2016-04-05 14:44:05 +0100 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2016-04-05 15:27:51 +0100 |
commit | 57f63917f08a8f6b042f8e223c6a6746ea2b6d01 (patch) | |
tree | 90696272cf9341e77db3682affb8930dfa5bbe73 | |
parent | 95e4c715fd120d2ab2dee093d5b730c80e75ff99 (diff) | |
download | busybox-w32-57f63917f08a8f6b042f8e223c6a6746ea2b6d01.tar.gz busybox-w32-57f63917f08a8f6b042f8e223c6a6746ea2b6d01.tar.bz2 busybox-w32-57f63917f08a8f6b042f8e223c6a6746ea2b6d01.zip |
ash: improve handling of invalid environment variable names
The code to replace invalid characters in environment variable names was
being invoked unconditionally because the value of 'end' was altered
in the loop to replace backslashes. Avoid this by using a separate
loop variable.
-rw-r--r-- | shell/ash.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/shell/ash.c b/shell/ash.c index 7cad34511..878c76da4 100644 --- a/shell/ash.c +++ b/shell/ash.c | |||
@@ -13486,7 +13486,7 @@ init(void) | |||
13486 | * variable called something other than PATH. This suggests we | 13486 | * variable called something other than PATH. This suggests we |
13487 | * haven't been invoked from an earlier instance of BusyBox. | 13487 | * haven't been invoked from an earlier instance of BusyBox. |
13488 | */ | 13488 | */ |
13489 | char *start, *end; | 13489 | char *start, *end, *s; |
13490 | struct passwd *pw; | 13490 | struct passwd *pw; |
13491 | 13491 | ||
13492 | for (envp = environ; envp && *envp; envp++) { | 13492 | for (envp = environ; envp && *envp; envp++) { |
@@ -13503,16 +13503,16 @@ init(void) | |||
13503 | continue; | 13503 | continue; |
13504 | } | 13504 | } |
13505 | 13505 | ||
13506 | /* convert backslashes to forward slashes */ | 13506 | /* convert backslashes to forward slashes in value */ |
13507 | if (!xp) { | 13507 | if (!xp) { |
13508 | for ( ++end; *end; ++end ) { | 13508 | for ( s=end+1; *s; ++s ) { |
13509 | if ( *end == '\\' ) { | 13509 | if ( *s == '\\' ) { |
13510 | *end = '/'; | 13510 | *s = '/'; |
13511 | } | 13511 | } |
13512 | } | 13512 | } |
13513 | } | 13513 | } |
13514 | 13514 | ||
13515 | /* check for invalid characters */ | 13515 | /* check for invalid characters in name */ |
13516 | for (start = *envp;start < end;start++) { | 13516 | for (start = *envp;start < end;start++) { |
13517 | if (!isdigit(*start) && !isalpha(*start) && *start != '_') { | 13517 | if (!isdigit(*start) && !isalpha(*start) && *start != '_') { |
13518 | break; | 13518 | break; |