Skip to content

Commit eabe45a

Browse files
committed
openssl: check if reneg_limit_callback is callable prior to calling
1 parent f9c3887 commit eabe45a

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

‎ext/openssl/xp_ssl.c‎

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1203,23 +1203,27 @@ static void php_openssl_limit_handshake_reneg(const SSL *ssl) /* {{{ */
12031203
/* The token level exceeds our allowed limit */
12041204
if (sslsock->reneg->tokens > sslsock->reneg->limit) {
12051205
zval *val;
1206-
1207-
12081206
sslsock->reneg->should_close = 1;
12091207

12101208
if (PHP_STREAM_CONTEXT(stream) && (val = php_stream_context_get_option(PHP_STREAM_CONTEXT(stream),
12111209
"ssl", "reneg_limit_callback")) != NULL
12121210
) {
1211+
zend_fcall_info_cache fcc;
1212+
1213+
if (!zend_is_callable(val, &fcc, NULL)) {
1214+
php_stream_warn(stream, UserspaceCallFailed, "SSL: failed invoking reneg limit notification callback");
1215+
return;
1216+
}
12131217
zval param, retval;
12141218

12151219
php_stream_to_zval(stream, &param);
12161220

12171221
/* Closing the stream inside this callback would segfault! */
12181222
stream->flags |= PHP_STREAM_FLAG_NO_FCLOSE;
1219-
if (FAILURE == call_user_function(NULL, NULL, val, &retval, 1, &param)) {
1220-
php_stream_warn(stream, UserspaceCallFailed, "SSL: failed invoking reneg limit notification callback");
1221-
}
1223+
zend_call_known_fcc(&fcc, &retval, 1, &param, NULL);
12221224
stream->flags ^= PHP_STREAM_FLAG_NO_FCLOSE;
1225+
/* Release potential trampoline */
1226+
zend_release_fcall_info_cache(&fcc);
12231227

12241228
/* If the reneg_limit_callback returned true don't auto-close */
12251229
if (Z_TYPE(retval) == IS_TRUE) {

0 commit comments

Comments
 (0)