com php-src: Avoid in-place modification: ext/curl/interface.c
| From: | Dmitry Stogov | Date: | Wed, 28 May 2014 06:15:15 +0000 |
| Subject: | com php-src: Avoid in-place modification: ext/curl/interface.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-78596@lists.php.net to get a copy of this message | ||
Commit: 066ea2204e225f061ae86a02dfad8ca480eaeffb
Author: Dmitry Stogov <dmitry@zend.com> Wed, 28 May 2014 10:15:15 +0400
Parents: cf603fb960cdf35a9f11b13dfe54e8639e844753
Branches: phpng
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=066ea2204e225f061ae86a02dfad8ca480eaeffb
Log:
Avoid in-place modification
Changed paths:
M ext/curl/interface.c
Diff:
diff --git a/ext/curl/interface.c b/ext/curl/interface.c
index 1735028..41c19ea 100644
--- a/ext/curl/interface.c
+++ b/ext/curl/interface.c
@@ -2532,37 +2532,34 @@ static int _php_curl_setopt(php_curl *ch, long option, zval *zvalue
TSRMLS_DC) /
* must be explicitly cast to long in curl_formadd
* use since curl needs a long not an int. */
if (!ch->safe_upload && *postval == '@') {
- char *type, *filename;
+ char *name, *type, *filename;
++postval;
php_error_docref("curl.curlfile" TSRMLS_CC, E_DEPRECATED,
"The usage of the @filename API for file uploading is deprecated. Please use the
CURLFile class instead");
- if ((type = php_memnstr(postval, ";type=", sizeof(";type=") - 1,
- postval + Z_STRLEN_P(current)))) {
+ name = estrndup(postval, Z_STRLEN_P(current));
+ if ((type = php_memnstr(name, ";type=", sizeof(";type=") - 1,
+ name + Z_STRLEN_P(current)))) {
*type = '\0';
}
- if ((filename = php_memnstr(postval, ";filename=", sizeof(";filename=") -
1,
- postval + Z_STRLEN_P(current)))) {
+ if ((filename = php_memnstr(name, ";filename=", sizeof(";filename=") - 1,
+ name + Z_STRLEN_P(current)))) {
*filename = '\0';
}
/* open_basedir check */
- if (php_check_open_basedir(postval TSRMLS_CC)) {
+ if (php_check_open_basedir(name TSRMLS_CC)) {
+ efree(name);
return FAILURE;
}
error = curl_formadd(&first, &last,
CURLFORM_COPYNAME, string_key->val,
CURLFORM_NAMELENGTH, string_key->len,
- CURLFORM_FILENAME, filename ? filename + sizeof(";filename=") - 1 : postval,
+ CURLFORM_FILENAME, filename ? filename + sizeof(";filename=") - 1 : name,
CURLFORM_CONTENTTYPE, type ? type + sizeof(";type=") - 1 :
"application/octet-stream",
- CURLFORM_FILE, postval,
+ CURLFORM_FILE, name,
CURLFORM_END);
- if (type) {
- *type = ';';
- }
- if (filename) {
- *filename = ';';
- }
+ efree(name);
} else {
error = curl_formadd(&first, &last,
CURLFORM_COPYNAME, string_key->val,