File tree 4 files changed +45
-5
lines changed
4 files changed +45
-5
lines changed Original file line number Diff line number Diff line change @@ -2,6 +2,10 @@ PHP NEWS
2
2
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
3
3
?? ??? ????, PHP 8.0.0rc2
4
4
5
+ - Curl:
6
+ . Fixed bug #80121 (Null pointer deref if CurlHandle directly instantiated).
7
+ (Nikita)
8
+
5
9
- SPL.
6
10
. Fixed bug #65387 (Circular references in SPL iterators are not garbage
7
11
collected). (Nikita)
Original file line number Diff line number Diff line change @@ -3308,6 +3308,12 @@ static void curl_free_obj(zend_object *object)
3308
3308
fprintf (stderr , "DTOR CALLED, ch = %x\n" , ch );
3309
3309
#endif
3310
3310
3311
+ if (!ch -> cp ) {
3312
+ /* Can happen if constructor throws. */
3313
+ zend_object_std_dtor (& ch -> std );
3314
+ return ;
3315
+ }
3316
+
3311
3317
_php_curl_verify_handlers (ch , 0 );
3312
3318
3313
3319
/*
@@ -3321,12 +3327,10 @@ static void curl_free_obj(zend_object *object)
3321
3327
*
3322
3328
* Libcurl commit d021f2e8a00 fix this issue and should be part of 7.28.2
3323
3329
*/
3324
- if (ch -> cp != NULL ) {
3325
- curl_easy_setopt (ch -> cp , CURLOPT_HEADERFUNCTION , curl_write_nothing );
3326
- curl_easy_setopt (ch -> cp , CURLOPT_WRITEFUNCTION , curl_write_nothing );
3330
+ curl_easy_setopt (ch -> cp , CURLOPT_HEADERFUNCTION , curl_write_nothing );
3331
+ curl_easy_setopt (ch -> cp , CURLOPT_WRITEFUNCTION , curl_write_nothing );
3327
3332
3328
- curl_easy_cleanup (ch -> cp );
3329
- }
3333
+ curl_easy_cleanup (ch -> cp );
3330
3334
3331
3335
/* cURL destructors should be invoked only by last curl handle */
3332
3336
if (-- (* ch -> clone ) == 0 ) {
Original file line number Diff line number Diff line change @@ -537,6 +537,12 @@ void curl_multi_free_obj(zend_object *object)
537
537
php_curl * ch ;
538
538
zval * pz_ch ;
539
539
540
+ if (!mh -> multi ) {
541
+ /* Can happen if constructor throws. */
542
+ zend_object_std_dtor (& mh -> std );
543
+ return ;
544
+ }
545
+
540
546
for (pz_ch = (zval * )zend_llist_get_first_ex (& mh -> easyh , & pos ); pz_ch ;
541
547
pz_ch = (zval * )zend_llist_get_next_ex (& mh -> easyh , & pos )) {
542
548
if (!(OBJ_FLAGS (Z_OBJ_P (pz_ch )) & IS_OBJ_FREE_CALLED )) {
Original file line number Diff line number Diff line change
1
+ --TEST--
2
+ Bug #80121: Null pointer deref if CurlHandle directly instantiated
3
+ --FILE--
4
+ <?php
5
+
6
+ try {
7
+ new CurlHandle ;
8
+ } catch (Error $ e ) {
9
+ echo $ e ->getMessage (), "\n" ;
10
+ }
11
+ try {
12
+ new CurlMultiHandle ;
13
+ } catch (Error $ e ) {
14
+ echo $ e ->getMessage (), "\n" ;
15
+ }
16
+ try {
17
+ new CurlShareHandle ;
18
+ } catch (Error $ e ) {
19
+ echo $ e ->getMessage (), "\n" ;
20
+ }
21
+
22
+ ?>
23
+ --EXPECT--
24
+ Cannot directly construct CurlHandle, use curl_init() instead
25
+ Cannot directly construct CurlMultiHandle, use curl_multi_init() instead
26
+ Cannot directly construct CurlShareHandle, use curl_share_init() instead
You can’t perform that action at this time.
0 commit comments