]> granicus.if.org Git - php/commitdiff
Fixed bug #30475 (curl_getinfo() may crash in some situations).
authorIlia Alshanetsky <iliaa@php.net>
Mon, 18 Oct 2004 22:41:24 +0000 (22:41 +0000)
committerIlia Alshanetsky <iliaa@php.net>
Mon, 18 Oct 2004 22:41:24 +0000 (22:41 +0000)
ext/curl/interface.c

index 46021ef4b94cca90e5f242ac6be3082ca2119e4e..b11dd2b0759f1e40069f761ab7f2ba94e4003720 100644 (file)
@@ -1336,10 +1336,13 @@ PHP_FUNCTION(curl_getinfo)
                switch (option) {
                        case CURLINFO_EFFECTIVE_URL: 
                        case CURLINFO_CONTENT_TYPE: {
-                               char *s_code;
+                               char *s_code = NULL;
 
-                               curl_easy_getinfo(ch->cp, option, &s_code);
-                               RETURN_STRING(s_code, 1);
+                               if (curl_easy_getinfo(ch->cp, option, &s_code) == CURLE_OK && s_code) {
+                                       RETURN_STRING(s_code, 1);
+                               } else {
+                                       RETURN_FALSE;
+                               }
                                break;
                        }
                        case CURLINFO_HTTP_CODE: 
@@ -1348,10 +1351,13 @@ PHP_FUNCTION(curl_getinfo)
                        case CURLINFO_FILETIME: 
                        case CURLINFO_SSL_VERIFYRESULT: 
                        case CURLINFO_REDIRECT_COUNT: {
-                               long code;
+                               long code = 0;
 
-                               curl_easy_getinfo(ch->cp, option, &code);
-                               RETURN_LONG(code);
+                               if (curl_easy_getinfo(ch->cp, option, &code) == CURLE_OK) {
+                                       RETURN_LONG(code);
+                               } else {
+                                       RETURN_FALSE;
+                               }
                                break;
                        }
                        case CURLINFO_TOTAL_TIME: 
@@ -1366,10 +1372,13 @@ PHP_FUNCTION(curl_getinfo)
                        case CURLINFO_CONTENT_LENGTH_UPLOAD: 
                        case CURLINFO_STARTTRANSFER_TIME:
                        case CURLINFO_REDIRECT_TIME: {
-                               double code;
+                               double code = 0.0;
 
-                               curl_easy_getinfo(ch->cp, option, &code);
-                               RETURN_DOUBLE(code);
+                               if (curl_easy_getinfo(ch->cp, option, &code) == CURLE_OK) {
+                                       RETURN_DOUBLE(code);
+                               } else {
+                                       RETURN_FALSE;
+                               }
                                break;
                        }
                }