From a4d2f0430723b4f0cf8a68e8b8a7e549658187ab Mon Sep 17 00:00:00 2001 From: Ilia Alshanetsky Date: Thu, 10 Aug 2006 14:40:13 +0000 Subject: Fixed overflow on 64bit systems in str_repeat() and wordwrap(). Disabled CURLOPT_FOLLOWLOCATION in curl when open_basedir or safe_mode are enabled. # Patches by Stefan E. --- ext/curl/interface.c | 11 ++++++++++- ext/curl/streams.c | 12 ++++++++++-- 2 files changed, 20 insertions(+), 3 deletions(-) (limited to 'ext/curl') diff --git a/ext/curl/interface.c b/ext/curl/interface.c index dc1efe8021..888a822e66 100644 --- a/ext/curl/interface.c +++ b/ext/curl/interface.c @@ -1168,7 +1168,6 @@ static int _php_curl_setopt(php_curl *ch, long option, zval **zvalue, zval *retu case CURLOPT_FTPLISTONLY: case CURLOPT_FTPAPPEND: case CURLOPT_NETRC: - case CURLOPT_FOLLOWLOCATION: case CURLOPT_PUT: #if CURLOPT_MUTE != 0 case CURLOPT_MUTE: @@ -1219,6 +1218,16 @@ static int _php_curl_setopt(php_curl *ch, long option, zval **zvalue, zval *retu convert_to_long_ex(zvalue); error = curl_easy_setopt(ch->cp, option, Z_LVAL_PP(zvalue)); break; + case CURLOPT_FOLLOWLOCATION: + convert_to_long_ex(zvalue); + if ((PG(open_basedir) && *PG(open_basedir)) || PG(safe_mode)) { + if (Z_LVAL_PP(zvalue) != 0) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "CURLOPT_FOLLOWLOCATION cannot be activated when in safe_mode or an open_basedir is set"); + RETURN_FALSE; + } + } + error = curl_easy_setopt(ch->cp, option, Z_LVAL_PP(zvalue)); + break; case CURLOPT_URL: case CURLOPT_PROXY: case CURLOPT_USERPWD: diff --git a/ext/curl/streams.c b/ext/curl/streams.c index f4600c00a7..a1758787da 100644 --- a/ext/curl/streams.c +++ b/ext/curl/streams.c @@ -349,11 +349,19 @@ php_stream *php_curl_stream_opener(php_stream_wrapper *wrapper, char *filename, } } if (mr > 1) { - curl_easy_setopt(curlstream->curl, CURLOPT_FOLLOWLOCATION, 1L); + if ((PG(open_basedir) && *PG(open_basedir)) || PG(safe_mode)) { + curl_easy_setopt(curlstream->curl, CURLOPT_FOLLOWLOCATION, 1); + } else { + curl_easy_setopt(curlstream->curl, CURLOPT_FOLLOWLOCATION, 0); + } curl_easy_setopt(curlstream->curl, CURLOPT_MAXREDIRS, mr); } } else { - curl_easy_setopt(curlstream->curl, CURLOPT_FOLLOWLOCATION, 1L); + if ((PG(open_basedir) && *PG(open_basedir)) || PG(safe_mode)) { + curl_easy_setopt(curlstream->curl, CURLOPT_FOLLOWLOCATION, 1); + } else { + curl_easy_setopt(curlstream->curl, CURLOPT_FOLLOWLOCATION, 0); + } curl_easy_setopt(curlstream->curl, CURLOPT_MAXREDIRS, 20L); } } -- cgit v1.2.1