diff options
author | Andrew J. Schorr <aschorr@telemetry-investments.com> | 2017-01-26 20:30:01 -0500 |
---|---|---|
committer | Andrew J. Schorr <aschorr@telemetry-investments.com> | 2017-01-26 20:30:01 -0500 |
commit | 901fa6ebd5e5fd165f4ad57180e96bd2251d2c04 (patch) | |
tree | aa2060ac59390e656621b93fc0040e329ed95dcc /node.c | |
parent | e1bfc3a49d45024f84f489ac6a7ebcd505ec203a (diff) | |
download | egawk-901fa6ebd5e5fd165f4ad57180e96bd2251d2c04.tar.gz egawk-901fa6ebd5e5fd165f4ad57180e96bd2251d2c04.tar.bz2 egawk-901fa6ebd5e5fd165f4ad57180e96bd2251d2c04.zip |
Fix possible string overrun in node.c:is_hex.
Diffstat (limited to 'node.c')
-rw-r--r-- | node.c | 7 |
1 files changed, 4 insertions, 3 deletions
@@ -41,12 +41,13 @@ int (*cmp_numbers)(const NODE *, const NODE *) = cmp_awknums; /* is_hex --- return true if a string looks like a hex value */ static bool -is_hex(const char *str) +is_hex(const char *str, const char *cpend) { + /* on entry, we know the string length is >= 1 */ if (*str == '-' || *str == '+') str++; - if (str[0] == '0' && (str[1] == 'x' || str[1] == 'X')) + if (str + 1 < cpend && str[0] == '0' && (str[1] == 'x' || str[1] == 'X')) return true; return false; @@ -113,7 +114,7 @@ r_force_number(NODE *n) if ( (! do_posix /* not POSIXLY paranoid and */ && (is_alpha((unsigned char) *cp) /* letter, or */ /* CANNOT do non-decimal and saw 0x */ - || (! do_non_decimal_data && is_hex(cp))))) { + || (! do_non_decimal_data && is_hex(cp, cpend))))) { goto badnum; } |