diff options
author | Andrew J. Schorr <aschorr@telemetry-investments.com> | 2017-01-26 20:35:08 -0500 |
---|---|---|
committer | Andrew J. Schorr <aschorr@telemetry-investments.com> | 2017-01-26 20:35:08 -0500 |
commit | c8bfe9cad177f47218999f16bea5cdbe7e3fa7d2 (patch) | |
tree | cf98acab0edaf192f07bc96c37c3a2b24e588d06 | |
parent | 901fa6ebd5e5fd165f4ad57180e96bd2251d2c04 (diff) | |
download | egawk-c8bfe9cad177f47218999f16bea5cdbe7e3fa7d2.tar.gz egawk-c8bfe9cad177f47218999f16bea5cdbe7e3fa7d2.tar.bz2 egawk-c8bfe9cad177f47218999f16bea5cdbe7e3fa7d2.zip |
Protect against string overrun when calling unsetenv.
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | str_array.c | 7 |
2 files changed, 10 insertions, 1 deletions
@@ -1,5 +1,9 @@ 2017-01-26 Andrew J. Schorr <aschorr@telemetry-investments.com> + * str_array.c (env_remove): Terminate string before calling unsetenv. + +2017-01-26 Andrew J. Schorr <aschorr@telemetry-investments.com> + * node.c (is_hex): Add a new argument pointing to the end of the string so we can check for string overrun. (r_force_number): Pass string end to is_hex. diff --git a/str_array.c b/str_array.c index d832380d..c559a39a 100644 --- a/str_array.c +++ b/str_array.c @@ -773,9 +773,14 @@ static NODE ** env_remove(NODE *symbol, NODE *subs) { NODE **val = str_remove(symbol, subs); + char save; - if (val != NULL) + if (val != NULL) { + save = subs->stptr[subs->stlen]; + subs->stptr[subs->stlen] = '\0'; (void) unsetenv(subs->stptr); + subs->stptr[subs->stlen] = save; + } return val; } |