mirror of
https://github.com/sheumann/hush.git
synced 2024-11-18 17:10:36 +00:00
Always copy the variable strings from environ to our variable structures in hush_main, instead of trying to share them.
This avoids problems stemming from the fact that GNO's environment implementation may deallocate those strings, in some cases before we're done with them. It also allows us to uppercase the variable names, although since we made them case-insensitive this only matters for display purposes (in "set" output).
This commit is contained in:
parent
3805dfc06e
commit
81652ca9c4
13
shell/hush.c
13
shell/hush.c
@ -8237,8 +8237,21 @@ int hush_main(int argc, char **argv)
|
||||
if (value) { /* paranoia */
|
||||
cur_var->next = xzalloc(sizeof(*cur_var));
|
||||
cur_var = cur_var->next;
|
||||
#ifndef __GNO__
|
||||
cur_var->varstr = *e;
|
||||
cur_var->max_len = strlen(*e);
|
||||
#else
|
||||
/* Don't try to use variable strings that are in the environment,
|
||||
* because GNO's environ implementation manages them and may free
|
||||
* them, which could cause problems for us. */
|
||||
cur_var->varstr = xstrdup(*e);
|
||||
cur_var->max_len = 0;
|
||||
|
||||
/* Uppercase environment variable names (which are lower-cased
|
||||
* in environ), to match the usual convention. */
|
||||
for (value = cur_var->varstr; *value != '='; ++value)
|
||||
*value = toupper(*value);
|
||||
#endif
|
||||
cur_var->flg_export = 1;
|
||||
}
|
||||
e++;
|
||||
|
Loading…
Reference in New Issue
Block a user