Skip to content

Commit d621283

Browse files
committed
Merge branch 'PHP-7.2' into PHP-7.3
2 parents e3e2a7f + 3ad0ebd commit d621283

File tree

3 files changed

+23
-6
lines changed

3 files changed

+23
-6
lines changed

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ PHP NEWS
2727
- Mbstring:
2828
. Fixed bug #77428 (mb_ereg_replace() doesn't replace a substitution
2929
variable). (Nikita)
30+
. Fixed bug #77454 (mb_scrub() silently truncates after a null byte).
31+
(64796c6e69 at gmail dot com)
3032

3133
- MySQLnd:
3234
. Fixed bug #75684 (In mysqlnd_ext_plugin.h the plugin methods family has

ext/mbstring/mbstring.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5010,11 +5010,9 @@ PHP_FUNCTION(mb_chr)
50105010
/* }}} */
50115011

50125012

5013-
static inline char* php_mb_scrub(const char* str, size_t str_len, const mbfl_encoding *enc)
5013+
static inline char* php_mb_scrub(const char* str, size_t str_len, const mbfl_encoding *enc, size_t *ret_len)
50145014
{
5015-
size_t ret_len;
5016-
5017-
return php_mb_convert_encoding_ex(str, str_len, enc, enc, &ret_len);
5015+
return php_mb_convert_encoding_ex(str, str_len, enc, enc, ret_len);
50185016
}
50195017

50205018

@@ -5027,6 +5025,7 @@ PHP_FUNCTION(mb_scrub)
50275025
char *enc_name = NULL;
50285026
size_t enc_name_len;
50295027
char *ret;
5028+
size_t ret_len;
50305029

50315030
ZEND_PARSE_PARAMETERS_START(1, 2)
50325031
Z_PARAM_STRING(str, str_len)
@@ -5039,13 +5038,13 @@ PHP_FUNCTION(mb_scrub)
50395038
RETURN_FALSE;
50405039
}
50415040

5042-
ret = php_mb_scrub(str, str_len, enc);
5041+
ret = php_mb_scrub(str, str_len, enc, &ret_len);
50435042

50445043
if (ret == NULL) {
50455044
RETURN_FALSE;
50465045
}
50475046

5048-
RETVAL_STRING(ret);
5047+
RETVAL_STRINGL(ret, ret_len);
50495048
efree(ret);
50505049
}
50515050
/* }}} */

ext/mbstring/tests/bug77454.phpt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
--TEST--
2+
Bug #77454: mb_scrub() silently truncates after a null byte
3+
--FILE--
4+
<?php
5+
$str = "before\0after";
6+
function test($str, $enc) {
7+
echo str_replace("\0", '\0', mb_scrub($str, $enc)), "\n";
8+
}
9+
test($str, 'latin1');
10+
test($str, 'utf-8');
11+
test($str, 'ascii');
12+
?>
13+
--EXPECT--
14+
before\0after
15+
before\0after
16+
before\0after

0 commit comments

Comments
 (0)