File tree Expand file tree Collapse file tree 4 files changed +45
-5
lines changed
Expand file tree Collapse file tree 4 files changed +45
-5
lines changed Original file line number Diff line number Diff line change @@ -2,6 +2,10 @@ PHP NEWS
22|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
33?? ??? ????, PHP 8.0.0rc2
44
5+ - Curl:
6+ . Fixed bug #80121 (Null pointer deref if CurlHandle directly instantiated).
7+ (Nikita)
8+
59- SPL.
610 . Fixed bug #65387 (Circular references in SPL iterators are not garbage
711 collected). (Nikita)
Original file line number Diff line number Diff line change @@ -3308,6 +3308,12 @@ static void curl_free_obj(zend_object *object)
33083308 fprintf (stderr , "DTOR CALLED, ch = %x\n" , ch );
33093309#endif
33103310
3311+ if (!ch -> cp ) {
3312+ /* Can happen if constructor throws. */
3313+ zend_object_std_dtor (& ch -> std );
3314+ return ;
3315+ }
3316+
33113317 _php_curl_verify_handlers (ch , 0 );
33123318
33133319 /*
@@ -3321,12 +3327,10 @@ static void curl_free_obj(zend_object *object)
33213327 *
33223328 * Libcurl commit d021f2e8a00 fix this issue and should be part of 7.28.2
33233329 */
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 );
33273332
3328- curl_easy_cleanup (ch -> cp );
3329- }
3333+ curl_easy_cleanup (ch -> cp );
33303334
33313335 /* cURL destructors should be invoked only by last curl handle */
33323336 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)
537537 php_curl * ch ;
538538 zval * pz_ch ;
539539
540+ if (!mh -> multi ) {
541+ /* Can happen if constructor throws. */
542+ zend_object_std_dtor (& mh -> std );
543+ return ;
544+ }
545+
540546 for (pz_ch = (zval * )zend_llist_get_first_ex (& mh -> easyh , & pos ); pz_ch ;
541547 pz_ch = (zval * )zend_llist_get_next_ex (& mh -> easyh , & pos )) {
542548 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