Skip to content

Commit 203a2da

Browse files
committed
Fixed bug #77329 (Buffer Overflow via overly long Error Messages)
1 parent 7d1df60 commit 203a2da

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

NEWS

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

55
- Core:
6+
. Fixed bug #77329 (Buffer Overflow via overly long Error Messages).
7+
(Dmitry)
68
. Fixed bug #77494 (Disabling class causes segfault on member access).
79
(Dmitry)
810
. Fixed bug #77498 (Custom extension Segmentation fault when declare static

Zend/zend_smart_str.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,12 @@ ZEND_API void ZEND_FASTCALL _smart_string_alloc(smart_string *str, size_t len)
155155
str->c = emalloc(SMART_STRING_START_LEN + 1);
156156
} else {
157157
str->a = ZEND_MM_ALIGNED_SIZE_EX(len + SMART_STRING_OVERHEAD, SMART_STRING_PAGE) - SMART_STRING_OVERHEAD;
158-
str->c = emalloc_large(str->a + 1);
158+
if (EXPECTED(str->a < (ZEND_MM_CHUNK_SIZE - SMART_STRING_OVERHEAD))) {
159+
str->c = emalloc_large(str->a + 1);
160+
} else {
161+
/* allocate a huge chunk */
162+
str->c = emalloc(str->a + 1);
163+
}
159164
}
160165
} else {
161166
if (UNEXPECTED((size_t) len > SIZE_MAX - str->len)) {

0 commit comments

Comments
 (0)