Skip to content

Commit 2e2c844

Browse files
committed
ext/standard: Reject NUL bytes in dl()
1 parent 278137c commit 2e2c844

4 files changed

Lines changed: 19 additions & 1 deletion

File tree

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,8 @@ PHP NEWS
254254
(Weilin Du)
255255
. getenv() and putenv() now raises a ValueError when the first argument
256256
contains null bytes. (Weilin Du)
257+
. dl() now raises a ValueError when the $extension_filename argument
258+
contains null bytes. (Weilin Du)
257259
. parse_str() now raises a ValueError when the $string argument contains
258260
null bytes. (Weilin Du)
259261
. proc_open() now raises a ValueError when the $cwd argument contains

UPGRADING

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,8 @@ PHP 8.6 UPGRADE NOTES
151151
argument value is passed.
152152
. getenv() and putenv() now raises a ValueError when the first argument
153153
contains null bytes.
154+
. dl() now raises a ValueError when the $extension_filename argument
155+
contains null bytes.
154156
. parse_str() now raises a ValueError when the $string argument contains
155157
null bytes.
156158
. linkinfo() now raises a ValueError when the $path argument is empty.

ext/standard/dl.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ PHPAPI PHP_FUNCTION(dl)
4343
size_t filename_len;
4444

4545
ZEND_PARSE_PARAMETERS_START(1, 1)
46-
Z_PARAM_STRING(filename, filename_len)
46+
Z_PARAM_PATH(filename, filename_len)
4747
ZEND_PARSE_PARAMETERS_END();
4848

4949
if (!PG(enable_dl)) {
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
--TEST--
2+
dl() rejects null bytes in extension filename
3+
--FILE--
4+
<?php
5+
6+
try {
7+
dl("foo\0bar");
8+
} catch (ValueError $e) {
9+
echo $e->getMessage(), "\n";
10+
}
11+
12+
?>
13+
--EXPECT--
14+
dl(): Argument #1 ($extension_filename) must not contain any null bytes

0 commit comments

Comments
 (0)