Skip to content

Commit ae0b1f5

Browse files
committed
Promote warnings to exceptions in dl() function
1 parent 80250da commit ae0b1f5

File tree

3 files changed

+19
-14
lines changed

3 files changed

+19
-14
lines changed

ext/standard/dl.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,13 @@ PHPAPI PHP_FUNCTION(dl)
5050
ZEND_PARSE_PARAMETERS_END();
5151

5252
if (!PG(enable_dl)) {
53-
php_error_docref(NULL, E_WARNING, "Dynamically loaded extensions aren't enabled");
54-
RETURN_FALSE;
53+
zend_throw_error(NULL, "Dynamically loaded extensions aren't enabled");
54+
return;
5555
}
5656

5757
if (filename_len >= MAXPATHLEN) {
58-
php_error_docref(NULL, E_WARNING, "File name exceeds the maximum allowed length of %d characters", MAXPATHLEN);
59-
RETURN_FALSE;
58+
zend_value_error("File name exceeds the maximum allowed length of %d characters", MAXPATHLEN);
59+
return;
6060
}
6161

6262
php_dl(filename, MODULE_TEMPORARY, return_value, 0);
@@ -265,7 +265,7 @@ PHP_MINFO_FUNCTION(dl)
265265

266266
PHPAPI void php_dl(char *file, int type, zval *return_value, int start_now)
267267
{
268-
php_error_docref(NULL, E_WARNING, "Cannot dynamically load %s - dynamic modules are not supported", file);
268+
zend_throw_error(NULL, "Cannot dynamically load %s - dynamic modules are not supported", file);
269269
RETVAL_FALSE;
270270
}
271271

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
--TEST--
22
dl() returns false when disabled via INI settings
3-
+--CREDITS--
3+
--CREDITS--
44
Tom Van Herreweghe <tom@theanalogguy.be>
55
User Group: PHP-WVL & PHPGent #PHPTestFest
66
--SKIPIF--
@@ -14,9 +14,11 @@ if (!in_array(php_sapi_name(), $enabled_sapi)) {
1414
enable_dl=0
1515
--FILE--
1616
<?php
17-
var_dump(dl('foo'));
17+
try {
18+
dl('foo');
19+
} catch (Error $exception) {
20+
echo $exception->getMessage() . "\n";
21+
}
1822
?>
19-
--EXPECTF--
20-
21-
Warning: dl(): Dynamically loaded extensions aren't enabled in %s on line %d
22-
bool(false)
23+
--EXPECT--
24+
Dynamically loaded extensions aren't enabled

ext/standard/tests/general_functions/dl-cve-2007-4887.phpt

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,11 @@ if (!in_array(php_sapi_name(), $enabled_sapi)) {
1111
enable_dl=1
1212
--FILE--
1313
<?php
14-
var_dump(dl(str_repeat("a", 8376757)));
14+
try {
15+
dl(str_repeat("a", 8376757));
16+
} catch (ValueError $exception) {
17+
echo $exception->getMessage() . "\n";
18+
}
1519
?>
1620
--EXPECTF--
17-
Warning: dl(): File name exceeds the maximum allowed length of %d characters in %s on line %d
18-
bool(false)
21+
File name exceeds the maximum allowed length of %d characters

0 commit comments

Comments
 (0)