-
Notifications
You must be signed in to change notification settings - Fork 7.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix crash when an invalid callback function is passed to CURLMOPT_PUS…
…HFUNCTION Previously this caused a SIGABRT. Closes GH-11639.
- Loading branch information
Showing
3 changed files
with
63 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
ext/curl/tests/curl_pushfunction_nonexistent_callback.phpt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
--TEST-- | ||
Test CURLMOPT_PUSHFUNCTION with non-existent callback function | ||
--CREDITS-- | ||
Davey Shafik | ||
Kévin Dunglas | ||
Niels Dossche | ||
--EXTENSIONS-- | ||
curl | ||
--SKIPIF-- | ||
<?php | ||
include 'skipif-nocaddy.inc'; | ||
|
||
$curl_version = curl_version(); | ||
if ($curl_version['version_number'] < 0x080100) { | ||
exit("skip: test may crash with curl < 8.1.0"); | ||
} | ||
?> | ||
--FILE-- | ||
<?php | ||
// Test adapted from curl_pushfunction.phpt | ||
|
||
$mh = curl_multi_init(); | ||
|
||
curl_multi_setopt($mh, CURLMOPT_PIPELINING, CURLPIPE_MULTIPLEX); | ||
curl_multi_setopt($mh, CURLMOPT_PUSHFUNCTION, "nonexistent"); | ||
|
||
$ch = curl_init(); | ||
curl_setopt($ch, CURLOPT_URL, "https://localhost/serverpush"); | ||
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_2_0); | ||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); | ||
|
||
curl_multi_add_handle($mh, $ch); | ||
|
||
$active = null; | ||
while(true) { | ||
$status = curl_multi_exec($mh, $active); | ||
|
||
do { | ||
$info = curl_multi_info_read($mh); | ||
if (false !== $info && $info['msg'] == CURLMSG_DONE) { | ||
$handle = $info['handle']; | ||
if ($handle !== null) { | ||
curl_multi_remove_handle($mh, $handle); | ||
curl_close($handle); | ||
break 2; | ||
} | ||
} | ||
} while ($info); | ||
} | ||
|
||
curl_multi_close($mh); | ||
?> | ||
--EXPECTF-- | ||
Warning: curl_multi_exec(): Cannot call the CURLMOPT_PUSHFUNCTION in %s on line %d |