summaryrefslogtreecommitdiffstats
path: root/parse.cxx
diff options
context:
space:
mode:
authorjistone <jistone>2006-12-11 22:03:12 +0000
committerjistone <jistone>2006-12-11 22:03:12 +0000
commit79e6d33f2b493b481da889dd64485c220a653c8c (patch)
treebc1a32dee1ea3cd9a80859a71023ed96912e0479 /parse.cxx
parent0672c11278edfaf71d4fd3d4f50a08abea817011 (diff)
downloadsystemtap-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.cxx9
1 files changed, 6 insertions, 3 deletions
diff --git a/parse.cxx b/parse.cxx
index 36b97dbc..4c881164 100644
--- a/parse.cxx
+++ b/parse.cxx
@@ -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