Skip to content

Commit 243865a

Browse files
MaxKellermannGirgias
authored andcommitted
ext/mbstring: fix new_value length check
Commit 8bbd095 added a check rejecting empty strings; in the merge commiot 379d9a1 however it was changed to a NULL check, one that did not make sense because ZSTR_VAL() is guaranteed to never be NULL; the length check was accidently removed by that merge commit. This bug was found by GCC's -Waddress warning: ext/mbstring/mbstring.c:748:27: warning: the comparison will always evaluate as ‘true’ for the address of ‘val’ will never be NULL [-Waddress] 748 | if (!new_value || !ZSTR_VAL(new_value)) { | ^ Closes GH-10532 Signed-off-by: George Peter Banyard <girgias@php.net>
1 parent ae16471 commit 243865a

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

NEWS

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ PHP NEWS
3535
. Fixed JSON scanner and parser generation build.
3636
(Daniel Black, Jakub Zelenka)
3737

38+
- MBString:
39+
. ext/mbstring: fix new_value length check. (Max Kellermann)
40+
3841
- Opcache:
3942
. Fix incorrect page_size check. (nielsdos)
4043

@@ -71,7 +74,7 @@ PHP NEWS
7174
- SAPI:
7275
. Fixed bug GHSA-54hq-v5wp-fqgv (DOS vulnerability when parsing multipart
7376
request body). (CVE-2023-0662) (Jakub Zelenka)
74-
77+
7578
02 Feb 2023, PHP 8.1.15
7679

7780
- Apache:

ext/mbstring/mbstring.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -745,7 +745,7 @@ static PHP_INI_MH(OnUpdate_mbstring_http_input)
745745
php_error_docref("ref.mbstring", E_DEPRECATED, "Use of mbstring.http_input is deprecated");
746746
}
747747

748-
if (!new_value || !ZSTR_VAL(new_value)) {
748+
if (!new_value || !ZSTR_LEN(new_value)) {
749749
const char *encoding = php_get_input_encoding();
750750
MBSTRG(http_input_set) = 0;
751751
_php_mb_ini_mbstring_http_input_set(encoding, strlen(encoding));

0 commit comments

Comments
 (0)