]> granicus.if.org Git - php/commitdiff
MFH: fix #38269 (fopen wrapper doesn't fail on invalid hostname with curlwrappers...
authorAntony Dovgal <tony2001@php.net>
Tue, 1 Aug 2006 13:28:03 +0000 (13:28 +0000)
committerAntony Dovgal <tony2001@php.net>
Tue, 1 Aug 2006 13:28:03 +0000 (13:28 +0000)
NEWS
ext/curl/streams.c

diff --git a/NEWS b/NEWS
index a26f62ebb9a1d15da8d7980b8a41518fac1a9747..6c766cbd9851c1181da10686b5658d94c7d1da1c 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -28,6 +28,8 @@ PHP                                                                        NEWS
   being applied when RAW filter is used. (Ilia)
 - Fixed bug #38278 (session_cache_expire()'s value does not match phpinfo's 
   session.cache_expire). (Tony)
+- Fixed bug #38269 (fopen wrapper doesn't fail on invalid hostname with 
+  curlwrappers enabled). (Tony)
 - Fixed bug #38261 (openssl_x509_parse() leaks with invalid cert) (Pierre)
 - Fixed bug #38255 (openssl possible leaks while passing keys) (Pierre)
 - Fixed bug #38253 (PDO produces segfault with default fetch mode). (Tony)
index 2941edf85546b4c876562f3528fd76ac05fbe6fb..f4600c00a7c7955c2e1bb8fa6fb1607a0b35e2d4 100644 (file)
@@ -396,15 +396,33 @@ php_stream *php_curl_stream_opener(php_stream_wrapper *wrapper, char *filename,
                /* fire up the connection; we need to detect a connection error here,
                 * otherwise the curlstream we return ends up doing nothing useful. */
                CURLMcode m;
+               CURLMsg *msg;
+               int msgs_left, msg_found = 0;
 
                while (CURLM_CALL_MULTI_PERFORM == (m = curl_multi_perform(curlstream->multi, &curlstream->pending))) {
                        ; /* spin */
                }
 
                if (m != CURLM_OK) {
-                       php_error_docref(NULL TSRMLS_CC, E_WARNING, "There was an error mcode=%d", m);
+                       php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", curl_multi_strerror(m));
+                       php_stream_close(stream);
+                       return NULL;
+               }
+               
+               /* we have only one curl handle here, even though we use multi syntax, 
+                * so it's ok to fail on any error */
+               while ((msg = curl_multi_info_read(curlstream->multi, &msgs_left))) {
+                       if (msg->data.result == CURLE_OK) {
+                               continue;
+                       } else {
+                               php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", curl_easy_strerror(msg->data.result));
+                               msg_found++;
+                       }
+               }
+               if (msg_found) {
+                       php_stream_close(stream);
+                       return NULL;
                }
-
        }
        
        return stream;