From: Eric Hawicz Date: Tue, 4 Jul 2023 15:45:57 +0000 (-0400) Subject: Merge pull request #759 from c3h2-ctf/truncation X-Git-Tag: json-c-0.17-20230812~16 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=e9d3ab209a8f774b476c8933f18a85bf9b611c16;p=thirdparty%2Fjson-c.git Merge pull request #759 from c3h2-ctf/truncation json_tokener_parse_ex: handle out of memory errors --- e9d3ab209a8f774b476c8933f18a85bf9b611c16 diff --cc json_tokener.c index 753d4f22,af03a857..25f41dcb --- a/json_tokener.c +++ b/json_tokener.c @@@ -992,14 -1030,12 +1031,17 @@@ struct json_object *json_tokener_parse_ if (!tok->is_double && tok->pb->buf[0] == '-' && json_parse_int64(tok->pb->buf, &num64) == 0) { + if (errno == ERANGE && (tok->flags & JSON_TOKENER_STRICT)) + { + tok->err = json_tokener_error_parse_number; + goto out; + } current = json_object_new_int64(num64); if (current == NULL) + { + tok->err = json_tokener_error_memory; goto out; + } } else if (!tok->is_double && tok->pb->buf[0] != '-' && json_parse_uint64(tok->pb->buf, &numuint64) == 0)