Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions ext/curl/interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -652,6 +652,9 @@ static int curl_progress(void *clientp, double dltotal, double dlnow, double ult
fprintf(stderr, "curl_progress() called\n");
fprintf(stderr, "clientp = %x, dltotal = %f, dlnow = %f, ultotal = %f, ulnow = %f\n", clientp, dltotal, dlnow, ultotal, ulnow);
#endif
if (!ZEND_FCC_INITIALIZED(ch->handlers.progress)) {
return rval;
}
Comment on lines +656 to +657
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't really understand how this can happen. It shouldn't be possible for this state to arise as this condition should be caught by the HANDLE_CURL_OPTION_CALLABLE, no? Or am I missing something here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no it is not, when I debugged php_curl_set_callable_handler earlier, the fcc was not initialised despite being succesful.


zval args[5];
zval retval;
Expand Down Expand Up @@ -690,6 +693,9 @@ static int curl_xferinfo(void *clientp, curl_off_t dltotal, curl_off_t dlnow, cu
fprintf(stderr, "curl_xferinfo() called\n");
fprintf(stderr, "clientp = %x, dltotal = %ld, dlnow = %ld, ultotal = %ld, ulnow = %ld\n", clientp, dltotal, dlnow, ultotal, ulnow);
#endif
if (!ZEND_FCC_INITIALIZED(ch->handlers.xferinfo)) {
return rval;
}

zval argv[5];
zval retval;
Expand Down
25 changes: 25 additions & 0 deletions ext/curl/tests/gh21023.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
--TEST--
GH-21023 (crash with CURLOPT_XFERINFOFUNCTION set with an invalid callback)
--EXTENSIONS--
curl
--INI--
error_reporting = E_ALL & ~E_DEPRECATED
--FILE--
<?php
include 'server.inc';
$host = curl_cli_server_start();
$url = "{$host}/get.inc";
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_NOPROGRESS, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_XFERINFOFUNCTION, $callback);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems the CURLOPT_PROGRESSFUNCTION and CURLOPT_XFERINFOFUNCTION are aliases... should we deprecate one, or explicitly mark one constant as the alias of the other?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PROGRESS is the one to be deprecated, we should at some point before next major release IMHO

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
curl_setopt($ch, CURLOPT_XFERINFOFUNCTION, $callback);
curl_setopt($ch, CURLOPT_XFERINFOFUNCTION, null);

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am afraid it is not the same as here, it s an undefined var.

curl_exec($ch);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_PROGRESSFUNCTION, $callback);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
curl_setopt($ch, CURLOPT_PROGRESSFUNCTION, $callback);
curl_setopt($ch, CURLOPT_PROGRESSFUNCTION, null);

curl_exec($ch);
?>
--EXPECTF--
Warning: Undefined variable $callback in %s on line %d

Warning: Undefined variable $callback in %s on line %d
Loading