[php-src] Issue #9339: OpenSSL oid_file path check contains uninitialized path
| From: | bukka | Date: | Mon, 15 Aug 2022 11:00:30 +0000 |
| Subject: | [php-src] Issue #9339: OpenSSL oid_file path check contains uninitialized path | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-242223@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/9339
Author: bukka
### Description
Due to bug in the error message creation that is used in oid_file check, the uninitialized
real_path is printed. It doesn't really make much sense to print the path as the
invalid one is either too long or contains \0 character
The following code:
```php
<?php
$configFile = __DIR__ . '/custom.cnf';
file_put_contents($configFile, sprintf("oid_file = %s\n", __DIR__ . '/' .
str_repeat('a', 9000)));
$pkey = openssl_pkey_new([ 'config' => $configFile ]);
```
Resulted in this output:
```
PHP Warning: openssl_pkey_new(): Path '�h,�' for oid_file option must be a valid file
path in ...
```
But I expected this output instead:
```
PHP Warning: openssl_pkey_new(): Path for oid_file option must be a valid file path in ...
```
### PHP Version
PHP 8.0
### Operating System
Linux