com php-src: Fixed wrong data type (all tests passed in ext/network now): ext/standard/head.c
| From: | Dmitry Stogov | Date: | Mon, 03 Mar 2014 10:27:45 +0000 |
| Subject: | com php-src: Fixed wrong data type (all tests passed in ext/network now): ext/standard/head.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-77791@lists.php.net to get a copy of this message | ||
Commit: eb7a9c7c47a030f3594d38baebf0555cfda3eda5
Author: Xinchen Hui <laruence@gmail.com> Mon, 3 Mar 2014 18:27:45 +0800
Parents: 4e9f2c7c00818b78f8ad4d0b3feaae407e66d80d
Branches: phpng
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=eb7a9c7c47a030f3594d38baebf0555cfda3eda5
Log:
Fixed wrong data type (all tests passed in ext/network now)
Changed paths:
M ext/standard/head.c
Diff:
diff --git a/ext/standard/head.c b/ext/standard/head.c
index 04a3c89..120a061 100644
--- a/ext/standard/head.c
+++ b/ext/standard/head.c
@@ -77,7 +77,7 @@ PHPAPI int php_setcookie(char *name, int name_len, char *value, int value_len, t
{
char *cookie;
int len=sizeof("Set-Cookie: ");
- char *dt;
+ zend_string *dt;
sapi_header_line ctr = {0};
int result;
zend_string *encoded_value = NULL;
@@ -117,8 +117,8 @@ PHPAPI int php_setcookie(char *name, int name_len, char *value, int value_len, t
* pick an expiry date in the past
*/
dt = php_format_date("D, d-M-Y H:i:s T", sizeof("D, d-M-Y H:i:s T")-1, 1, 0
TSRMLS_CC);
- snprintf(cookie, len + 100, "Set-Cookie: %s=deleted; expires=%s; Max-Age=0", name, dt);
- efree(dt);
+ snprintf(cookie, len + 100, "Set-Cookie: %s=deleted; expires=%s; Max-Age=0", name,
dt->val);
+ STR_FREE(dt);
} else {
snprintf(cookie, len + 100, "Set-Cookie: %s=%s", name, value ? encoded_value->val :
"");
if (expires > 0) {
@@ -127,16 +127,16 @@ PHPAPI int php_setcookie(char *name, int name_len, char *value, int value_len,
t
strlcat(cookie, "; expires=", len + 100);
dt = php_format_date("D, d-M-Y H:i:s T", sizeof("D, d-M-Y H:i:s T")-1,
expires, 0 TSRMLS_CC);
/* check to make sure that the year does not exceed 4 digits in length */
- p = zend_memrchr(dt, '-', strlen(dt));
+ p = zend_memrchr(dt->val, '-', dt->len);
if (!p || *(p + 5) != ' ') {
- efree(dt);
+ STR_FREE(dt);
efree(cookie);
STR_FREE(encoded_value);
zend_error(E_WARNING, "Expiry date cannot have a year greater than 9999");
return FAILURE;
}
- strlcat(cookie, dt, len + 100);
- efree(dt);
+ strlcat(cookie, dt->val, len + 100);
+ STR_FREE(dt);
snprintf(tsdelta, sizeof(tsdelta), "%li", (long) difftime(expires, time(NULL)));
strlcat(cookie, "; Max-Age=", len + 100);