Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ PHP NEWS
. Fixed bug #73342 (Vulnerability in php-fpm by changing stdin to
non-blocking). (Nikita)

- mbstring:
. Fixed bug #76532 (Integer overflow and excessive memory usage
in mb_strimwidth). (MarcusSchwarz)

- phpdbg:
. Fix arginfo wrt. optional/required parameters. (cmb)

Expand Down
2 changes: 1 addition & 1 deletion ext/mbstring/libmbfl/mbfl/mbfilter.c
Original file line number Diff line number Diff line change
Expand Up @@ -1875,7 +1875,7 @@ mbfl_strimwidth(
mbfl_string_init(result);
result->no_language = string->no_language;
result->no_encoding = string->no_encoding;
mbfl_memory_device_init(&pc.device, width, 0);
mbfl_memory_device_init(&pc.device, MIN(string->len, width), 0);

/* output code filter */
pc.decoder = mbfl_convert_filter_new(
Expand Down
7 changes: 7 additions & 0 deletions ext/mbstring/libmbfl/mbfl/mbfilter.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,13 @@
#define MBFL_OUTPUTFILTER_ILLEGAL_MODE_LONG 2
#define MBFL_OUTPUTFILTER_ILLEGAL_MODE_ENTITY 3

/*
* convenience macros
*/
#ifndef MIN
#define MIN(a,b) ((a)<(b)?(a):(b))
#endif

/*
* buffering converter
*/
Expand Down
12 changes: 12 additions & 0 deletions ext/mbstring/tests/bug76532.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
--TEST--
Bug #76532 (Integer overflow and excessive memory usage in mb_strimwidth)
--SKIPIF--
<?php require 'skipif.inc'; ?>
--FILE--
<?php
$string_to_trim = '得很幸福。有一天,一个长得很丑的老人带着一只木马来到王';
$width = 2147483647;
var_dump(mb_strimwidth($string_to_trim, 0, $width));
?>
--EXPECT--
string(81) "得很幸福。有一天,一个长得很丑的老人带着一只木马来到王"