diff options
author | jistone <jistone> | 2006-12-11 22:03:12 +0000 |
---|---|---|
committer | jistone <jistone> | 2006-12-11 22:03:12 +0000 |
commit | 79e6d33f2b493b481da889dd64485c220a653c8c (patch) | |
tree | bc1a32dee1ea3cd9a80859a71023ed96912e0479 /parse.cxx | |
parent | 0672c11278edfaf71d4fd3d4f50a08abea817011 (diff) | |
download | systemtap-steved-79e6d33f2b493b481da889dd64485c220a653c8c.tar.gz systemtap-steved-79e6d33f2b493b481da889dd64485c220a653c8c.tar.xz systemtap-steved-79e6d33f2b493b481da889dd64485c220a653c8c.zip |
2006-12-11 Josh Stone <joshua.i.stone@intel.com>
* parse.cxx (parse::parse_literal): Enforce the lower bound on
negative literals.
Diffstat (limited to 'parse.cxx')
-rw-r--r-- | parse.cxx | 9 |
1 files changed, 6 insertions, 3 deletions
@@ -1253,16 +1253,19 @@ parser::parse_literal () // NB: we allow controlled overflow from LLONG_MIN .. ULLONG_MAX // Actually, this allows all the way from -ULLONG_MAX to ULLONG_MAX, - // since the lexer only gives us positive digit strings. + // since the lexer only gives us positive digit strings, but we'll + // limit it to LLONG_MIN when a '-' operator is fed into the literal. errno = 0; long long value = (long long) strtoull (startp, & endp, 0); - if (neg) - value = -value; if (errno == ERANGE || errno == EINVAL || *endp != '\0' + || (neg && (unsigned long long) value > 9223372036854775808ULL) || (unsigned long long) value > 18446744073709551615ULL || value < -9223372036854775807LL-1) throw parse_error ("number invalid or out of range"); + if (neg) + value = -value; + l = new literal_number (value); } else |