mirror of
https://github.com/json-c/json-c.git
synced 2026-04-04 21:09:06 +08:00
Fix double to int cast overflow in json_object_get_int64.
Found with autofuzz in GDAL
This commit is contained in:
@@ -688,6 +688,10 @@ int64_t json_object_get_int64(const struct json_object *jso)
|
|||||||
case json_type_int:
|
case json_type_int:
|
||||||
return jso->o.c_int64;
|
return jso->o.c_int64;
|
||||||
case json_type_double:
|
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;
|
return (int64_t)jso->o.c_double;
|
||||||
case json_type_boolean:
|
case json_type_boolean:
|
||||||
return jso->o.c_boolean;
|
return jso->o.c_boolean;
|
||||||
|
|||||||
Reference in New Issue
Block a user