[ruby/json] Fix potential out of bound read in json_string_unescape.

https://github.com/ruby/json/commit/cf242d89a0
This commit is contained in:
Jean Boussier 2025-03-11 18:49:14 +01:00 committed by Hiroshi SHIBATA
parent 8cc85dc00f
commit e6a2cf9fd7
No known key found for this signature in database
GPG Key ID: F9CF13417264FAC2

View File

@ -608,7 +608,7 @@ static VALUE json_string_unescape(JSON_ParserState *state, const char *string, c
buffer = RSTRING_PTR(result);
bufferStart = buffer;
while ((pe = memchr(pe, '\\', stringEnd - pe))) {
while (pe < stringEnd && (pe = memchr(pe, '\\', stringEnd - pe))) {
unescape = (char *) "?";
unescape_len = 1;
if (pe > p) {