diff options
author | Ron Yorston <rmy@pobox.com> | 2015-09-30 11:17:17 +0100 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2015-09-30 11:17:17 +0100 |
commit | ff5ef2920fd216e4c2f8f17cfd64f46cc9adc60c (patch) | |
tree | 3bbf55689ad5afba76436f7387171ad5941f2f67 | |
parent | 249f68e3ceaaabdd40964f8ab85645da529ec469 (diff) | |
download | busybox-w32-ff5ef2920fd216e4c2f8f17cfd64f46cc9adc60c.tar.gz busybox-w32-ff5ef2920fd216e4c2f8f17cfd64f46cc9adc60c.tar.bz2 busybox-w32-ff5ef2920fd216e4c2f8f17cfd64f46cc9adc60c.zip |
ash: replace invalid characters in variable names with '_'
Microsoft Windows has environment variables with names like
'ProgramFiles(x86)'. When the environment is imported into the
shell replace invalid characters with underscores.
-rw-r--r-- | shell/ash.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/shell/ash.c b/shell/ash.c index f23a3e1ff..80846da0f 100644 --- a/shell/ash.c +++ b/shell/ash.c | |||
@@ -13471,10 +13471,16 @@ init(void) | |||
13471 | if (!(end=strchr(*envp, '='))) | 13471 | if (!(end=strchr(*envp, '='))) |
13472 | continue; | 13472 | continue; |
13473 | 13473 | ||
13474 | /* make all variable names uppercase */ | 13474 | for (start = *envp;start < end;start++) { |
13475 | for (start = *envp;start < end;start++) | 13475 | /* make all variable names uppercase */ |
13476 | *start = toupper(*start); | 13476 | *start = toupper(*start); |
13477 | 13477 | ||
13478 | /* replace invalid characters with underscores */ | ||
13479 | if (!isdigit(*start) && !isalpha(*start) && *start != '_') { | ||
13480 | *start = '_'; | ||
13481 | } | ||
13482 | } | ||
13483 | |||
13478 | /* skip conversion of variables known to cause problems */ | 13484 | /* skip conversion of variables known to cause problems */ |
13479 | if ( strncmp(*envp, "SYSTEMROOT=", 11) == 0 || | 13485 | if ( strncmp(*envp, "SYSTEMROOT=", 11) == 0 || |
13480 | strncmp(*envp, "COMSPEC=", 8) == 0 ) { | 13486 | strncmp(*envp, "COMSPEC=", 8) == 0 ) { |