diff --git a/ext/curl/interface.c b/ext/curl/interface.c index 8c6d6a0c1f20..5631effb0895 100644 --- a/ext/curl/interface.c +++ b/ext/curl/interface.c @@ -2172,7 +2172,7 @@ static zend_result _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue /* no need to build the mime structure for empty hashtables; also works around https://github.com/curl/curl/issues/6455 */ curl_easy_setopt(ch->cp, CURLOPT_POSTFIELDS, ""); - error = curl_easy_setopt(ch->cp, CURLOPT_POSTFIELDSIZE, 0L); + error = curl_easy_setopt(ch->cp, CURLOPT_POSTFIELDSIZE_LARGE, (curl_off_t) 0); } else { return build_mime_structure_from_hash(ch, zvalue); } @@ -2180,7 +2180,7 @@ static zend_result _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue zend_string *tmp_str; zend_string *str = zval_get_tmp_string(zvalue, &tmp_str); /* with curl 7.17.0 and later, we can use COPYPOSTFIELDS, but we have to provide size before */ - error = curl_easy_setopt(ch->cp, CURLOPT_POSTFIELDSIZE, ZSTR_LEN(str)); + error = curl_easy_setopt(ch->cp, CURLOPT_POSTFIELDSIZE_LARGE, (curl_off_t) ZSTR_LEN(str)); error = curl_easy_setopt(ch->cp, CURLOPT_COPYPOSTFIELDS, ZSTR_VAL(str)); zend_tmp_string_release(tmp_str); } diff --git a/ext/curl/tests/curl_post_large_string.phpt b/ext/curl/tests/curl_post_large_string.phpt new file mode 100644 index 000000000000..526fc78dcbd8 --- /dev/null +++ b/ext/curl/tests/curl_post_large_string.phpt @@ -0,0 +1,30 @@ +--TEST-- +CURL post data larger than 2GB (to test CURLOPT_POSTFIELDSIZE_LARGE) +--INI-- +memory_limit=3G +--SKIPIF-- + +--EXTENSIONS-- +curl +--FILE-- + true, + CURLOPT_POST => true, + CURLOPT_POSTFIELDS => $data, +]); + +$response = curl_exec($ch); +var_dump($response); + +?> +--EXPECTF-- +string(28) "Content-length: =2147483748="