Skip to content

Commit 84dcf57

Browse files
committed
Fix GH-9339: OpenSSL oid_file path check warning contains uninitialized path
1 parent 7c6316a commit 84dcf57

File tree

3 files changed

+32
-3
lines changed

3 files changed

+32
-3
lines changed

NEWS

+4
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ PHP NEWS
2020
. Fixed bug GH-9033 (Loading blacklist file can fail due to negative length).
2121
(cmb)
2222

23+
- OpenSSL:
24+
. Fixed bug GH-9339 (OpenSSL oid_file path check warning contains
25+
uninitialized path). (Jakub Zelenka)
26+
2327
- PDO_SQLite:
2428
. Fixed bug GH-9032 (SQLite3 authorizer crashes on NULL values). (cmb)
2529

ext/openssl/openssl.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -506,15 +506,15 @@ static bool php_openssl_check_path_ex(
506506
error_msg = "must not contain any null bytes";
507507
error_type = E_ERROR;
508508
} else if (expand_filepath(fs_file_path, real_path) == NULL) {
509-
error_msg = "The argument must be a valid file path";
509+
error_msg = "must be a valid file path";
510510
}
511511

512512
if (error_msg != NULL) {
513513
if (arg_num == 0) {
514514
const char *option_title = option_name ? option_name : "unknown";
515515
const char *option_label = is_from_array ? "array item" : "option";
516-
php_error_docref(NULL, E_WARNING, "Path '%s' for %s %s %s",
517-
real_path, option_title, option_label, error_msg);
516+
php_error_docref(NULL, E_WARNING, "Path for %s %s %s",
517+
option_title, option_label, error_msg);
518518
} else if (is_from_array && option_name != NULL) {
519519
php_openssl_check_path_error(
520520
arg_num, error_type, "option %s array item %s", option_name, error_msg);

ext/openssl/tests/gh9339.phpt

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
--TEST--
2+
GH-9339: oid_file path check warning contains uninitialized path
3+
--SKIPIF--
4+
<?php
5+
if (!extension_loaded("openssl")) die("skip openssl not loaded");
6+
?>
7+
--FILE--
8+
<?php
9+
$configCode = <<<CONFIG
10+
oid_file = %s
11+
[ req ]
12+
default_bits = 1024
13+
CONFIG;
14+
15+
$configFile = __DIR__ . '/gh9339.cnf';
16+
file_put_contents($configFile, sprintf($configCode, __DIR__ . '/' . str_repeat('a', 9000)));
17+
openssl_pkey_new([ 'config' => $configFile ]);
18+
?>
19+
--CLEAN--
20+
<?php
21+
@unlink(__DIR__ . '/gh9339.cnf');
22+
?>
23+
--EXPECTF--
24+
25+
Warning: openssl_pkey_new(): Path for oid_file option must be a valid file path in %s on line %d

0 commit comments

Comments
 (0)