Bug #74402 [NEW]: segfault on random_bytes, bin2hex, openssl_seal

From: Date: Mon, 10 Apr 2017 10:19:37 +0000
Subject: Bug #74402 [NEW]: segfault on random_bytes, bin2hex, openssl_seal
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-208423@lists.php.net to get a copy of this message
From: hboomsma at hostnet dot nl Operating system: Linux PHP version: 7.1.3 Package: Reproducible crash Bug Type: Bug Bug description:segfault on random_bytes, bin2hex, openssl_seal Description: ------------ When using the output of bin2hex(random_bytes) in a openssl_seal, segaults starts occurring. We got around this problem in our source by prepending an 'A' to the random bytes before calling bin2hex on them. Crashed on all versions supporting random_bytes: https://3v4l.org/lrLgW Test script: --------------- <?php define( 'KEY', <<<'KEY' -----BEGIN PUBLIC KEY----- MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAqvjCLfpS0MyilIjR+IsH HPH8TqFUCw4kTAVmTy9SDZV9hHYY2EPgrlTd7gvMP/DWipvBD6Y5w2bPdAQoXr5D qEKAGkE+1El4hS8XyuOdYXSYTDH1HPSlFiGdgsnlkFcbh/fJyzIKBaGLnWxsjhiS deiI7KuEkI9zt+X2r4KqFt/dhnXz0kcB1M7qyhQ6Rvijgjy/A1LsN4ZAREFLCEjb 1AP9nk0QAUHWcG5MvbgsE20Pn4R5wFsMFBTvNmb34jHFREgR9j4DYcV5FFR3tKb8 3XtjE9/kjfK29BSpiyXZs8PSqDhO00vh6txUB4VfkVUD2Bi93rxDeyALnCW7My+l YwIDAQAB -----END PUBLIC KEY----- KEY ); $bytes = random_bytes(32); $iv = ''; for ($i = 0; $i < 100; $i++) { openssl_seal(bin2hex($bytes), $sealed_data, $env_keys, [KEY], 'AES256', $iv); \ob_end_clean(); } Expected result: ---------------- no output and no crash Actual result: -------------- Notice: P ��� in /in/lrLgW on line 22 Process exited with code 139. -- Edit bug report at https://bugs.php.net/bug.php?id=74402&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=74402&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=74402&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=74402&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=74402&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=74402&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=74402&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=74402&r=needscript Try newer version: https://bugs.php.net/fix.php?id=74402&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=74402&r=support Expected behavior: https://bugs.php.net/fix.php?id=74402&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=74402&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=74402&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=74402&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=74402&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=74402&r=dst IIS Stability: https://bugs.php.net/fix.php?id=74402&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=74402&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=74402&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=74402&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=74402&r=mysqlcfg

« previous php.bugs (#208423) next »