mirror of
https://github.com/php/php-src.git
synced 2025-08-16 14:08:47 +02:00
Fixed bug #76532 (excessive memory usage in mb_strimwidth)
This commit is contained in:
parent
f6430e3fe2
commit
bf5a802f5a
4 changed files with 24 additions and 1 deletions
4
NEWS
4
NEWS
|
@ -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)
|
||||
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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
|
||||
*/
|
||||
|
|
12
ext/mbstring/tests/bug76532.phpt
Normal file
12
ext/mbstring/tests/bug76532.phpt
Normal file
|
@ -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) "得很幸福。有一天,一个长得很丑的老人带着一只木马来到王"
|
Loading…
Add table
Add a link
Reference in a new issue