From: Kurt Schwehr Date: Mon, 11 Sep 2017 14:23:00 +0000 (-0700) Subject: Fix double to int cast overflow in json_object_get_int64. X-Git-Tag: json-c-0.13-20171207~46^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F361%2Fhead;p=thirdparty%2Fjson-c.git Fix double to int cast overflow in json_object_get_int64. Found with autofuzz in GDAL --- diff --git a/json_object.c b/json_object.c index 9ffb149d..8cd5922e 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;