From 334d154acc8974b615810363bf1012d487effa11 Mon Sep 17 00:00:00 2001 From: Ilia Alshanetsky Date: Wed, 29 Jul 2009 13:44:16 +0000 Subject: [PATCH] Fixed bug #45141 (setcookie will output expires years of >4 digits). --- NEWS | 1 + ext/standard/head.c | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/NEWS b/NEWS index bc85cc174d..a4691ee770 100644 --- a/NEWS +++ b/NEWS @@ -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 diff --git a/ext/standard/head.c b/ext/standard/head.c index 6ebb89a51f..e563dfe7ea 100644 --- a/ext/standard/head.c +++ b/ext/standard/head.c @@ -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); } -- 2.40.0