Replace stack-allocated "struct utsname" in hush_main with dynamic allocation.

This commit is contained in:
Stephen Heumann 2014-12-02 13:56:38 -06:00
parent 81652ca9c4
commit 1ac41557b2

View File

@ -8266,9 +8266,12 @@ int hush_main(int argc, char **argv)
#if ENABLE_HUSH_BASH_COMPAT
/* Set (but not export) HOSTNAME unless already set */
if (!get_local_var_value("HOSTNAME")) {
struct utsname uts;
uname(&uts);
set_local_var_from_halves("HOSTNAME", uts.nodename);
struct utsname *uts = malloc(sizeof(struct utsname));
if (uts) {
uname(uts);
set_local_var_from_halves("HOSTNAME", uts->nodename);
free(uts);
}
}
/* bash also exports SHLVL and _,
* and sets (but doesn't export) the following variables: