[php-src] Issue #20833: Division by zero in zif_mb_str_pad with UTF-32 and boolean pad string

From: Date: Sun, 04 Jan 2026 14:38:57 +0000
Subject: [php-src] Issue #20833: Division by zero in zif_mb_str_pad with UTF-32 and boolean pad string
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-251476@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/20833 Author: vi3tL0u1s ### Description The following code: ```php <?php $utf8 = "test"; $utf32 = mb_convert_encoding($utf8, 'UTF-32', 'UTF-8'); var_dump(mb_str_pad($utf32, 44, true, STR_PAD_RIGHT, "UTF-32")); ``` Resulted in this output: ``` AddressSanitizer:DEADLYSIGNAL ================================================================= ==2359430==ERROR: AddressSanitizer: FPE on unknown address 0x56162afce4dc (pc 0x56162afce4dc bp 0x7fffbdb7f4f0 sp 0x7fffbdb7f2c0 T0) #0 0x56162afce4dc in zif_mb_str_pad /path/to/php-src/ext/mbstring/mbstring.c:5880 #1 0x56162bc8943b in ZEND_DO_ICALL_SPEC_RETVAL_USED_HANDLER /path/to/php-src/Zend/zend_vm_execute.h:1421 #2 0x56162bdf34ee in execute_ex /path/to/php-src/Zend/zend_vm_execute.h:116441 #3 0x56162be086cc in zend_execute /path/to/php-src/Zend/zend_vm_execute.h:121924 #4 0x56162bf771fa in zend_execute_script /path/to/php-src/Zend/zend.c:1981 #5 0x56162b992d50 in php_execute_script_ex /path/to/php-src/main/main.c:2645 #6 0x56162b9931bb in php_execute_script /path/to/php-src/main/main.c:2685 #7 0x56162bf7d17b in do_cli /path/to/php-src/sapi/cli/php_cli.c:951 #8 0x56162bf7f8eb in main /path/to/php-src/sapi/cli/php_cli.c:1362 #9 0x7f222035ed8f in __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58 #10 0x7f222035ee3f in __libc_start_main_impl ../csu/libc-start.c:392 #11 0x56162aa06eb4 in _start (/path/to/php-src/sapi/cli/php+0x606eb4) AddressSanitizer can not provide additional info. SUMMARY: AddressSanitizer: FPE /path/to/php-src/ext/mbstring/mbstring.c:5880 in zif_mb_str_pad ==2359430==ABORTING ``` ### Commit ``` cb63e4f998b ``` ### Configurations ```bash CC="clang" CXX="clang++" CFLAGS="-fsanitize=address -g -O0" CXXFLAGS="-fsanitize=address -g -O0" ./configure --enable-debug --enable-address-sanitizer --disable-shared --with-pic ``` ### PHP Version ```plain PHP 8.6.0-dev (cli) (built: Jan 5 2026 01:08:08) (NTS DEBUG) Copyright (c) The PHP Group Zend Engine v4.6.0-dev, Copyright (c) Zend Technologies with Zend OPcache v8.6.0-dev, Copyright (c), by Zend Technologies ``` ### Operating System Ubuntu 22.04

« previous php.bugs (#251476) next »