aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2015-09-30 11:17:17 +0100
committerRon Yorston <rmy@pobox.com>2015-09-30 11:17:17 +0100
commitff5ef2920fd216e4c2f8f17cfd64f46cc9adc60c (patch)
tree3bbf55689ad5afba76436f7387171ad5941f2f67
parent249f68e3ceaaabdd40964f8ab85645da529ec469 (diff)
downloadbusybox-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.c10
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 ) {