@@ -96,7 +96,7 @@ static ZEND_ATTRIBUTE_UNUSED unsigned long php_curl_ssl_id(void)
96
96
# define php_curl_ret (__ret ) RETVAL_FALSE; return;
97
97
#endif
98
98
99
- static int php_curl_option_str (php_curl * ch , zend_long option , const char * str , const size_t len )
99
+ static zend_result php_curl_option_str (php_curl * ch , zend_long option , const char * str , const size_t len )
100
100
{
101
101
if (strlen (str ) != len ) {
102
102
zend_value_error ("%s(): cURL option must not contain any null bytes" , get_active_function_name ());
@@ -109,7 +109,7 @@ static int php_curl_option_str(php_curl *ch, zend_long option, const char *str,
109
109
return error == CURLE_OK ? SUCCESS : FAILURE ;
110
110
}
111
111
112
- static int php_curl_option_url (php_curl * ch , const char * url , const size_t len ) /* {{{ */
112
+ static zend_result php_curl_option_url (php_curl * ch , const char * url , const size_t len ) /* {{{ */
113
113
{
114
114
/* Disable file:// if open_basedir are used */
115
115
if (PG (open_basedir ) && * PG (open_basedir )) {
@@ -131,7 +131,7 @@ static int php_curl_option_url(php_curl *ch, const char *url, const size_t len)
131
131
}
132
132
/* }}} */
133
133
134
- void _php_curl_verify_handlers (php_curl * ch , int reporterror ) /* {{{ */
134
+ void _php_curl_verify_handlers (php_curl * ch , bool reporterror ) /* {{{ */
135
135
{
136
136
php_stream * stream ;
137
137
@@ -226,7 +226,7 @@ static HashTable *curl_get_gc(zend_object *object, zval **table, int *n);
226
226
static zend_function * curl_get_constructor (zend_object * object );
227
227
static zend_object * curl_clone_obj (zend_object * object );
228
228
php_curl * init_curl_handle_into_zval (zval * curl );
229
- static inline int build_mime_structure_from_hash (php_curl * ch , zval * zpostfields );
229
+ static inline zend_result build_mime_structure_from_hash (php_curl * ch , zval * zpostfields );
230
230
231
231
/* {{{ PHP_INI_BEGIN */
232
232
PHP_INI_BEGIN ()
@@ -1249,7 +1249,7 @@ static zend_object *curl_clone_obj(zend_object *object) {
1249
1249
1250
1250
postfields = & clone_ch -> postfields ;
1251
1251
if (Z_TYPE_P (postfields ) != IS_UNDEF ) {
1252
- if (build_mime_structure_from_hash (clone_ch , postfields ) != SUCCESS ) {
1252
+ if (build_mime_structure_from_hash (clone_ch , postfields ) == FAILURE ) {
1253
1253
zend_throw_exception (NULL , "Failed to clone CurlHandle" , 0 );
1254
1254
return & clone_ch -> std ;
1255
1255
}
@@ -1391,7 +1391,7 @@ static size_t curl_write(char *data, size_t size, size_t nmemb, void *ctx)
1391
1391
php_error_docref (NULL , E_WARNING , "Could not call the CURLOPT_WRITEFUNCTION" );
1392
1392
length = -1 ;
1393
1393
} else if (!Z_ISUNDEF (retval )) {
1394
- _php_curl_verify_handlers (ch , 1 );
1394
+ _php_curl_verify_handlers (ch , /* reporterror */ true );
1395
1395
length = zval_get_long (& retval );
1396
1396
}
1397
1397
@@ -1413,7 +1413,7 @@ static int curl_fnmatch(void *ctx, const char *pattern, const char *string)
1413
1413
int rval = CURL_FNMATCHFUNC_FAIL ;
1414
1414
zval argv [3 ];
1415
1415
zval retval ;
1416
- int error ;
1416
+ zend_result error ;
1417
1417
zend_fcall_info fci ;
1418
1418
1419
1419
GC_ADDREF (& ch -> std );
@@ -1435,7 +1435,7 @@ static int curl_fnmatch(void *ctx, const char *pattern, const char *string)
1435
1435
if (error == FAILURE ) {
1436
1436
php_error_docref (NULL , E_WARNING , "Cannot call the CURLOPT_FNMATCH_FUNCTION" );
1437
1437
} else if (!Z_ISUNDEF (retval )) {
1438
- _php_curl_verify_handlers (ch , 1 );
1438
+ _php_curl_verify_handlers (ch , /* reporterror */ true );
1439
1439
rval = zval_get_long (& retval );
1440
1440
}
1441
1441
zval_ptr_dtor (& argv [0 ]);
@@ -1459,7 +1459,7 @@ static size_t curl_progress(void *clientp, double dltotal, double dlnow, double
1459
1459
1460
1460
zval argv [5 ];
1461
1461
zval retval ;
1462
- int error ;
1462
+ zend_result error ;
1463
1463
zend_fcall_info fci ;
1464
1464
1465
1465
GC_ADDREF (& ch -> std );
@@ -1483,7 +1483,7 @@ static size_t curl_progress(void *clientp, double dltotal, double dlnow, double
1483
1483
if (error == FAILURE ) {
1484
1484
php_error_docref (NULL , E_WARNING , "Cannot call the CURLOPT_PROGRESSFUNCTION" );
1485
1485
} else if (!Z_ISUNDEF (retval )) {
1486
- _php_curl_verify_handlers (ch , 1 );
1486
+ _php_curl_verify_handlers (ch , /* reporterror */ true );
1487
1487
if (0 != zval_get_long (& retval )) {
1488
1488
rval = 1 ;
1489
1489
}
@@ -1509,7 +1509,7 @@ static size_t curl_read(char *data, size_t size, size_t nmemb, void *ctx)
1509
1509
case PHP_CURL_USER : {
1510
1510
zval argv [3 ];
1511
1511
zval retval ;
1512
- int error ;
1512
+ zend_result error ;
1513
1513
zend_fcall_info fci ;
1514
1514
1515
1515
GC_ADDREF (& ch -> std );
@@ -1537,7 +1537,7 @@ static size_t curl_read(char *data, size_t size, size_t nmemb, void *ctx)
1537
1537
php_error_docref (NULL , E_WARNING , "Cannot call the CURLOPT_READFUNCTION" );
1538
1538
length = CURL_READFUNC_ABORT ;
1539
1539
} else if (!Z_ISUNDEF (retval )) {
1540
- _php_curl_verify_handlers (ch , 1 );
1540
+ _php_curl_verify_handlers (ch , /* reporterror */ true );
1541
1541
if (Z_TYPE (retval ) == IS_STRING ) {
1542
1542
length = MIN ((int ) (size * nmemb ), Z_STRLEN (retval ));
1543
1543
memcpy (data , Z_STRVAL (retval ), length );
@@ -1577,7 +1577,7 @@ static size_t curl_write_header(char *data, size_t size, size_t nmemb, void *ctx
1577
1577
case PHP_CURL_USER : {
1578
1578
zval argv [2 ];
1579
1579
zval retval ;
1580
- int error ;
1580
+ zend_result error ;
1581
1581
zend_fcall_info fci ;
1582
1582
1583
1583
GC_ADDREF (& ch -> std );
@@ -1599,7 +1599,7 @@ static size_t curl_write_header(char *data, size_t size, size_t nmemb, void *ctx
1599
1599
php_error_docref (NULL , E_WARNING , "Could not call the CURLOPT_HEADERFUNCTION" );
1600
1600
length = -1 ;
1601
1601
} else if (!Z_ISUNDEF (retval )) {
1602
- _php_curl_verify_handlers (ch , 1 );
1602
+ _php_curl_verify_handlers (ch , /* reporterror */ true );
1603
1603
length = zval_get_long (& retval );
1604
1604
}
1605
1605
zval_ptr_dtor (& argv [0 ]);
@@ -1988,7 +1988,7 @@ static void free_cb(void *arg) /* {{{ */
1988
1988
/* }}} */
1989
1989
#endif
1990
1990
1991
- static inline int build_mime_structure_from_hash (php_curl * ch , zval * zpostfields ) /* {{{ */
1991
+ static inline zend_result build_mime_structure_from_hash (php_curl * ch , zval * zpostfields ) /* {{{ */
1992
1992
{
1993
1993
HashTable * postfields = Z_ARRVAL_P (zpostfields );
1994
1994
CURLcode error = CURLE_OK ;
@@ -2260,7 +2260,7 @@ PHP_FUNCTION(curl_copy_handle)
2260
2260
2261
2261
postfields = & ch -> postfields ;
2262
2262
if (Z_TYPE_P (postfields ) != IS_UNDEF ) {
2263
- if (build_mime_structure_from_hash (dupch , postfields ) != SUCCESS ) {
2263
+ if (build_mime_structure_from_hash (dupch , postfields ) == FAILURE ) {
2264
2264
zval_ptr_dtor (return_value );
2265
2265
php_error_docref (NULL , E_WARNING , "Cannot rebuild mime structure" );
2266
2266
RETURN_FALSE ;
@@ -2269,7 +2269,7 @@ PHP_FUNCTION(curl_copy_handle)
2269
2269
}
2270
2270
/* }}} */
2271
2271
2272
- static int _php_curl_setopt (php_curl * ch , zend_long option , zval * zvalue , bool is_array_config ) /* {{{ */
2272
+ static zend_result _php_curl_setopt (php_curl * ch , zend_long option , zval * zvalue , bool is_array_config ) /* {{{ */
2273
2273
{
2274
2274
CURLcode error = CURLE_OK ;
2275
2275
zend_long lval ;
@@ -2435,12 +2435,12 @@ static int _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue, bool i
2435
2435
if ((option == CURLOPT_PROTOCOLS || option == CURLOPT_REDIR_PROTOCOLS ) &&
2436
2436
(PG (open_basedir ) && * PG (open_basedir )) && (lval & CURLPROTO_FILE )) {
2437
2437
php_error_docref (NULL , E_WARNING , "CURLPROTO_FILE cannot be activated when an open_basedir is set" );
2438
- return 1 ;
2438
+ return FAILURE ;
2439
2439
}
2440
2440
# if defined(ZTS )
2441
2441
if (option == CURLOPT_DNS_USE_GLOBAL_CACHE && lval ) {
2442
2442
php_error_docref (NULL , E_WARNING , "CURLOPT_DNS_USE_GLOBAL_CACHE cannot be activated when thread safety is enabled" );
2443
- return 1 ;
2443
+ return FAILURE ;
2444
2444
}
2445
2445
# endif
2446
2446
error = curl_easy_setopt (ch -> cp , option , lval );
@@ -2533,7 +2533,7 @@ static int _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue, bool i
2533
2533
{
2534
2534
zend_string * tmp_str ;
2535
2535
zend_string * str = zval_get_tmp_string (zvalue , & tmp_str );
2536
- int ret = php_curl_option_str (ch , option , ZSTR_VAL (str ), ZSTR_LEN (str ));
2536
+ zend_result ret = php_curl_option_str (ch , option , ZSTR_VAL (str ), ZSTR_LEN (str ));
2537
2537
zend_tmp_string_release (tmp_str );
2538
2538
return ret ;
2539
2539
}
@@ -2563,7 +2563,7 @@ static int _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue, bool i
2563
2563
} else {
2564
2564
zend_string * tmp_str ;
2565
2565
zend_string * str = zval_get_tmp_string (zvalue , & tmp_str );
2566
- int ret = php_curl_option_str (ch , option , ZSTR_VAL (str ), ZSTR_LEN (str ));
2566
+ zend_result ret = php_curl_option_str (ch , option , ZSTR_VAL (str ), ZSTR_LEN (str ));
2567
2567
zend_tmp_string_release (tmp_str );
2568
2568
return ret ;
2569
2569
}
@@ -2583,7 +2583,7 @@ static int _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue, bool i
2583
2583
{
2584
2584
zend_string * tmp_str ;
2585
2585
zend_string * str = zval_get_tmp_string (zvalue , & tmp_str );
2586
- int ret = php_curl_option_url (ch , ZSTR_VAL (str ), ZSTR_LEN (str ));
2586
+ zend_result ret = php_curl_option_url (ch , ZSTR_VAL (str ), ZSTR_LEN (str ));
2587
2587
zend_tmp_string_release (tmp_str );
2588
2588
return ret ;
2589
2589
}
@@ -2757,7 +2757,7 @@ static int _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue, bool i
2757
2757
zend_tmp_string_release (tmp_val );
2758
2758
if (!slist ) {
2759
2759
php_error_docref (NULL , E_WARNING , "Could not build curl_slist" );
2760
- return 1 ;
2760
+ return FAILURE ;
2761
2761
}
2762
2762
} ZEND_HASH_FOREACH_END ();
2763
2763
@@ -2881,7 +2881,7 @@ static int _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue, bool i
2881
2881
{
2882
2882
zend_string * tmp_str ;
2883
2883
zend_string * str = zval_get_tmp_string (zvalue , & tmp_str );
2884
- int ret ;
2884
+ zend_result ret ;
2885
2885
2886
2886
if (ZSTR_LEN (str ) && php_check_open_basedir (ZSTR_VAL (str ))) {
2887
2887
zend_tmp_string_release (tmp_str );
@@ -3056,7 +3056,7 @@ PHP_FUNCTION(curl_exec)
3056
3056
3057
3057
ch = Z_CURL_P (zid );
3058
3058
3059
- _php_curl_verify_handlers (ch , 1 );
3059
+ _php_curl_verify_handlers (ch , /* reporterror */ true );
3060
3060
3061
3061
_php_curl_cleanup_handle (ch );
3062
3062
@@ -3427,7 +3427,7 @@ static void curl_free_obj(zend_object *object)
3427
3427
return ;
3428
3428
}
3429
3429
3430
- _php_curl_verify_handlers (ch , 0 );
3430
+ _php_curl_verify_handlers (ch , /* reporterror */ false );
3431
3431
3432
3432
/*
3433
3433
* Libcurl is doing connection caching. When easy handle is cleaned up,
0 commit comments