Skip to content

Commit a942cf5

Browse files
committed
Fix #72595: php_output_handler_append illegal write access
We must make sure that `handler->buffer.size + grow_max` does not overflow, so we're using `safe_erealloc()` instead. Closes GH-7241.
1 parent 33f8dfb commit a942cf5

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ PHP NEWS
22
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
33
?? ??? ????, PHP 7.4.23
44

5+
- Core:
6+
. Fixed bug #72595 (php_output_handler_append illegal write access). (cmb)
7+
58
- Standard:
69
. Fixed bug #72146 (Integer overflow on substr_replace). (cmb)
710

main/output.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -889,7 +889,7 @@ static inline int php_output_handler_append(php_output_handler *handler, const p
889889
size_t grow_buf = PHP_OUTPUT_HANDLER_INITBUF_SIZE(buf->used - (handler->buffer.size - handler->buffer.used));
890890
size_t grow_max = MAX(grow_int, grow_buf);
891891

892-
handler->buffer.data = erealloc(handler->buffer.data, handler->buffer.size + grow_max);
892+
handler->buffer.data = safe_erealloc(handler->buffer.data, 1, handler->buffer.size, grow_max);
893893
handler->buffer.size += grow_max;
894894
}
895895
memcpy(handler->buffer.data + handler->buffer.used, buf->data, buf->used);

0 commit comments

Comments
 (0)