From 57f63917f08a8f6b042f8e223c6a6746ea2b6d01 Mon Sep 17 00:00:00 2001 From: Ron Yorston Date: Tue, 5 Apr 2016 14:44:05 +0100 Subject: 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. --- shell/ash.c | 12 ++++++------ 1 file 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) * variable called something other than PATH. This suggests we * haven't been invoked from an earlier instance of BusyBox. */ - char *start, *end; + char *start, *end, *s; struct passwd *pw; for (envp = environ; envp && *envp; envp++) { @@ -13503,16 +13503,16 @@ init(void) continue; } - /* convert backslashes to forward slashes */ + /* convert backslashes to forward slashes in value */ if (!xp) { - for ( ++end; *end; ++end ) { - if ( *end == '\\' ) { - *end = '/'; + for ( s=end+1; *s; ++s ) { + if ( *s == '\\' ) { + *s = '/'; } } } - /* check for invalid characters */ + /* check for invalid characters in name */ for (start = *envp;start < end;start++) { if (!isdigit(*start) && !isalpha(*start) && *start != '_') { break; -- cgit v1.2.3-55-g6feb