1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

streams/memory: Ensure internal string is NUL terminated (#20812)

zend_string_truncate() doesn't put a NUL byte.
This commit is contained in:
Niels Dossche
2026-01-02 09:03:17 -08:00
committed by GitHub
parent 30ed81314b
commit 5484ebcc49

View File

@@ -247,8 +247,8 @@ static int php_stream_memory_set_option(php_stream *stream, int option, int valu
size_t old_size = ZSTR_LEN(ms->data);
ms->data = zend_string_realloc(ms->data, newsize, 0);
memset(ZSTR_VAL(ms->data) + old_size, 0, newsize - old_size);
ZSTR_VAL(ms->data)[ZSTR_LEN(ms->data)] = '\0';
}
ZSTR_VAL(ms->data)[ZSTR_LEN(ms->data)] = '\0';
return PHP_STREAM_OPTION_RETURN_OK;
}
}