Skip to content

Commit

Permalink
Fixed bug #45141 (setcookie will output expires years of >4 digits).
Browse files Browse the repository at this point in the history
  • Loading branch information
Ilia Alshanetsky committed Jul 29, 2009
1 parent b2449e3 commit 334d154
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions NEWS
Expand Up @@ -69,6 +69,7 @@ PHP NEWS
(Sriram Natarajan)
- Fixed bug #48182 (ssl handshake fails during asynchronous socket connection).
(Sriram Natarajan)
- Fixed bug #45141 (setcookie will output expires years of >4 digits). (Ilia)
- Fixed bug #44144 (spl_autoload_functions() should return object instance
when appropriate). (Hannes, Etienne)
- Fixed bug #42434 (ImageLine w/ antialias = 1px shorter). (wojjie at gmail dot
Expand Down
10 changes: 10 additions & 0 deletions ext/standard/head.c
Expand Up @@ -110,8 +110,18 @@ PHPAPI int php_setcookie(char *name, int name_len, char *value, int value_len, t
} else {
snprintf(cookie, len + 100, "Set-Cookie: %s=%s", name, value ? encoded_value : "");
if (expires > 0) {
char *p;
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));
if (*(p + 5) != ' ') {
efree(dt);
efree(cookie);
efree(encoded_value);
zend_error(E_WARNING, "Expiry date cannot have a year greater then 9999");
return FAILURE;
}
strlcat(cookie, dt, len + 100);
efree(dt);
}
Expand Down

0 comments on commit 334d154

Please sign in to comment.