summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLloyd Hilaiel <lloyd@hilaiel.com>2011-04-25 09:50:46 -0600
committerLloyd Hilaiel <lloyd@hilaiel.com>2011-04-25 09:50:46 -0600
commit807d3635055017206acaecf2e56b08ebc9e2f51c (patch)
tree8c0699cb937dc3627950fab872bf38bc933105cd /src
parentec8204ddf795a233d8c7053f026ba7e2208b529a (diff)
downloadyajl-807d3635055017206acaecf2e56b08ebc9e2f51c.tar.gz
fix a bug in overflow detection in integer parsing routine, add overflow tests (now that we always rep integers in 64bit entities regardless of arch word size)
Diffstat (limited to 'src')
-rw-r--r--src/yajl_parser.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/yajl_parser.c b/src/yajl_parser.c
index 65d5ed6..69508b7 100644
--- a/src/yajl_parser.c
+++ b/src/yajl_parser.c
@@ -42,12 +42,15 @@ yajl_parse_integer(const unsigned char *number, unsigned int length)
if (*pos == '+') { pos++; }
while (pos < number + length) {
-
if ( ret > MAX_VALUE_TO_MULTIPLY ) {
errno = ERANGE;
return sign == 1 ? LLONG_MAX : LLONG_MIN;
}
ret *= 10;
+ if (LLONG_MAX - ret < (*pos - '0')) {
+ errno = ERANGE;
+ return sign == 1 ? LLONG_MAX : LLONG_MIN;
+ }
ret += (*pos++ - '0');
}