diff options
author | Nikita Popov <nikita.ppv@gmail.com> | 2017-04-09 13:15:04 +0200 |
---|---|---|
committer | Nikita Popov <nikita.ppv@gmail.com> | 2017-04-09 13:15:04 +0200 |
commit | 430eea84b84a8c9d733a38cafaa32d494cadf13b (patch) | |
tree | ba373cfac48f4fb06e8a1ab91e2fc18063d15e3b /ext/standard/head.c | |
parent | 4ee6b52d0f4483c6e063b2dd3bb7af1c8a94300d (diff) | |
parent | 84ef6fa80dbfc1ff8942209b13d9fb5439409729 (diff) | |
download | php-git-430eea84b84a8c9d733a38cafaa32d494cadf13b.tar.gz |
Merge branch 'PHP-7.1'
Diffstat (limited to 'ext/standard/head.c')
-rw-r--r-- | ext/standard/head.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/ext/standard/head.c b/ext/standard/head.c index 52cdb34534..b8632c70ed 100644 --- a/ext/standard/head.c +++ b/ext/standard/head.c @@ -138,6 +138,8 @@ PHPAPI int php_setcookie(zend_string *name, zend_string *value, time_t expires, if (expires > 0) { const char *p; char tsdelta[13]; + double diff; + strlcat(cookie, 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); /* check to make sure that the year does not exceed 4 digits in length */ @@ -152,7 +154,11 @@ PHPAPI int php_setcookie(zend_string *name, zend_string *value, time_t expires, strlcat(cookie, ZSTR_VAL(dt), len + 100); zend_string_free(dt); - snprintf(tsdelta, sizeof(tsdelta), ZEND_LONG_FMT, (zend_long) difftime(expires, time(NULL))); + diff = difftime(expires, time(NULL)); + if (diff < 0) { + diff = 0; + } + snprintf(tsdelta, sizeof(tsdelta), ZEND_LONG_FMT, (zend_long) diff); strlcat(cookie, COOKIE_MAX_AGE, len + 100); strlcat(cookie, tsdelta, len + 100); } |