summaryrefslogtreecommitdiff
path: root/ext/standard/head.c
diff options
context:
space:
mode:
authorIlia Alshanetsky <iliaa@php.net>2009-07-29 13:44:16 +0000
committerIlia Alshanetsky <iliaa@php.net>2009-07-29 13:44:16 +0000
commit06a2acc527f294b852a9e0976f63dce34d1a3e91 (patch)
tree5637f712c4ac99dbaa4680196d42409a6be1cbfa /ext/standard/head.c
parente29bccaae2c9bb00fd426d46f504f3c32e9446b8 (diff)
downloadphp-git-06a2acc527f294b852a9e0976f63dce34d1a3e91.tar.gz
Fixed bug #45141 (setcookie will output expires years of >4 digits).
Diffstat (limited to 'ext/standard/head.c')
-rw-r--r--ext/standard/head.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/ext/standard/head.c b/ext/standard/head.c
index c0a7314df8..c27ef9f34d 100644
--- a/ext/standard/head.c
+++ b/ext/standard/head.c
@@ -124,8 +124,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);
}