From 46afe5a792cd0aed20fbdfbae05f968d33e316a5 Mon Sep 17 00:00:00 2001 From: Ilia Alshanetsky Date: Mon, 15 Sep 2003 00:08:05 +0000 Subject: [PATCH] MFH: Fixed bug #25530 (checkdate incorrectly handles floats) --- NEWS | 3 ++- ext/standard/datetime.c | 31 +++++-------------------------- 2 files changed, 7 insertions(+), 27 deletions(-) diff --git a/NEWS b/NEWS index c73958454a..4226dcbe79 100644 --- a/NEWS +++ b/NEWS @@ -4,9 +4,10 @@ PHP 4 NEWS - Made MCVE extension available on win32. (Jani) - Added apache_get_version() function. (Ilia) - Fixed disk_total_space() and disk_free_space() under FreeBSD. (Jon Parise) -- Fixed crash bug when non-existing save/serializer handler was used. (Jani) +[B- Fixed crash bug when non-existing save/serializer handler was used. (Jani) - Fixed memory leak in gethostbynamel() if an error occurs. (Sara) - Fixed FastCGI being unable to bind to a specific IP. (Sascha) +- Fixed bug #25530 (checkdate incorrectly handles floats). (Ilia) - Fixed bug #25525 (ldap_explode_dn() crashes when passed invalid dn). (Sara, patch by: mikael dot suvi at trigger dot ee) - Fixed bug #25504 (pcre_match_all() crashes when passed only 2 parameters). diff --git a/ext/standard/datetime.c b/ext/standard/datetime.c index 1c14aa3699..75e42670d2 100644 --- a/ext/standard/datetime.c +++ b/ext/standard/datetime.c @@ -782,37 +782,16 @@ char *php_std_date(time_t t) Returns true(1) if it is a valid date in gregorian calendar */ PHP_FUNCTION(checkdate) { - pval **month, **day, **year; - int m, d, y, res=0; - - if (ZEND_NUM_ARGS() != 3 || - zend_get_parameters_ex(3, &month, &day, &year) == FAILURE) { - WRONG_PARAM_COUNT; - } + long m, d, y; - if(Z_TYPE_PP(year) == IS_STRING) { - res = is_numeric_string(Z_STRVAL_PP(year), Z_STRLEN_PP(year), NULL, NULL, 0); - if(res!=IS_LONG && res !=IS_DOUBLE) { - RETURN_FALSE; - } - } - convert_to_long_ex(day); - convert_to_long_ex(month); - convert_to_long_ex(year); - y = Z_LVAL_PP(year); - m = Z_LVAL_PP(month); - d = Z_LVAL_PP(day); - - if (y < 1 || y > 32767) { - RETURN_FALSE; - } - if (m < 1 || m > 12) { + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lll", &m, &d, &y) == FAILURE) { RETURN_FALSE; } - if (d < 1 || d > phpday_tab[isleap(y)][m - 1]) { + + if (y < 1 || y > 32767 || m < 1 || m > 12 || d < 1 || d > phpday_tab[isleap(y)][m - 1]) { RETURN_FALSE; } - RETURN_TRUE; /* True : This month, day, year arguments are valid */ + RETURN_TRUE; /* True : This month, day, year arguments are valid */ } /* }}} */ -- 2.50.1