summaryrefslogtreecommitdiff
path: root/json_object.c
diff options
context:
space:
mode:
authorKurt Schwehr <schwehr@google.com>2017-09-11 07:23:00 -0700
committerKurt Schwehr <schwehr@google.com>2017-09-11 07:23:00 -0700
commitd9879c25335ade46e7cba3d86151fb6cf5aadaed (patch)
tree932a5e951b4067baf956f0048c88d03a0683b3b2 /json_object.c
parent5454c4eaa3a55f38e8ce90cbdb130a1923baffa9 (diff)
downloadjson-c-d9879c25335ade46e7cba3d86151fb6cf5aadaed.tar.gz
Fix double to int cast overflow in json_object_get_int64.
Found with autofuzz in GDAL
Diffstat (limited to 'json_object.c')
-rw-r--r--json_object.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/json_object.c b/json_object.c
index 9ffb149..8cd5922 100644
--- a/json_object.c
+++ b/json_object.c
@@ -688,6 +688,10 @@ int64_t json_object_get_int64(const struct json_object *jso)
case json_type_int:
return jso->o.c_int64;
case json_type_double:
+ if (jso->o.c_double >= INT64_MAX)
+ return INT64_MAX;
+ if (jso->o.c_double <= INT64_MIN)
+ return INT64_MIN;
return (int64_t)jso->o.c_double;
case json_type_boolean:
return jso->o.c_boolean;