diff options
author | Andrew J. Schorr <aschorr@telemetry-investments.com> | 2016-06-26 21:10:25 -0400 |
---|---|---|
committer | Andrew J. Schorr <aschorr@telemetry-investments.com> | 2016-06-26 21:10:25 -0400 |
commit | a7b4445ceb1d355911a8a367b8db79b225094c43 (patch) | |
tree | a8c6db4710384cae3a8d8da228c018c1b8538c7f | |
parent | 2b0495afae3d744127f3b6c18e98819feafbface (diff) | |
download | egawk-a7b4445ceb1d355911a8a367b8db79b225094c43.tar.gz egawk-a7b4445ceb1d355911a8a367b8db79b225094c43.tar.bz2 egawk-a7b4445ceb1d355911a8a367b8db79b225094c43.zip |
When checking for trailing spaces in numeric strings, avoid running off the end.
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | mpfr.c | 2 | ||||
-rw-r--r-- | node.c | 2 |
3 files changed, 8 insertions, 2 deletions
@@ -1,5 +1,11 @@ 2016-06-26 Andrew J. Schorr <aschorr@telemetry-investments.com> + * node.c (r_force_number): When checking for trailing spaces, protect + against running off the end of the string. + * mpfr.c (force_mpnum): Ditto. + +2016-06-26 Andrew J. Schorr <aschorr@telemetry-investments.com> + * builtin.c (do_print): There's actually no reason to test whether a value is a number, since the STRCUR flag and stfmt value contain all the necessary info, as in awk.h:force_string. @@ -327,7 +327,7 @@ force_mpnum(NODE *n, int do_nondec, int use_locale) IEEE_FMT(n->mpg_numbr, tval); done: /* trailing space is OK for NUMBER */ - while (isspace((unsigned char) *ptr)) + while (ptr < cpend && isspace((unsigned char) *ptr)) ptr++; *cpend = save; if (errno == 0 && ptr == cpend) @@ -136,7 +136,7 @@ r_force_number(NODE *n) } /* POSIX says trailing space is OK for NUMBER */ - while (isspace((unsigned char) *ptr)) + while (ptr < cpend && isspace((unsigned char) *ptr)) ptr++; if (errno == 0) { |