Skip to content

Commit a57fdea

Browse files
committedOct 1, 2023
Add assertion to mb_utf7imap_to_wchar to catch buffer overrun
I don't believe such a buffer overrun will ever occur, but just in case the code is changed in the future, it will be good to have an assertion here to help catch bugs. (A similar assertion is already used in the UTF-7 version of this function.)
1 parent 3944bb0 commit a57fdea

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed
 

‎ext/mbstring/libmbfl/filters/mbfilter_utf7imap.c

+1
Original file line numberDiff line numberDiff line change
@@ -616,6 +616,7 @@ static size_t mb_utf7imap_to_wchar(unsigned char **in, size_t *in_len, uint32_t
616616
if (p == e && base64) {
617617
/* UTF7-IMAP doesn't allow strings to end in Base64 mode
618618
* One space in output buffer was reserved just for this */
619+
ZEND_ASSERT(out < limit);
619620
*out++ = MBFL_BAD_INPUT;
620621
}
621622

0 commit comments

Comments
 (0)