tony2001 Thu Jun 7 08:46:32 2007 UTC Modified files: /php-src/ext/calendar cal_unix.c /php-src/ext/date php_date.c /php-src/ext/mime_magic mime_magic.c /php-src/main main.c Log: check return value of *time_r() functions for NULL more checks will follow http://cvs.php.net/viewvc.cgi/php-src/ext/calendar/cal_unix.c?r1=1.22&r2=1.23&diff_format=u Index: php-src/ext/calendar/cal_unix.c diff -u php-src/ext/calendar/cal_unix.c:1.22 php-src/ext/calendar/cal_unix.c:1.23 --- php-src/ext/calendar/cal_unix.c:1.22 Mon Jan 1 09:29:21 2007 +++ php-src/ext/calendar/cal_unix.c Thu Jun 7 08:46:32 2007 @@ -47,8 +47,11 @@ } ta = php_localtime_r(×tamp, &tmbuf); + if (!ta) { + RETURN_FALSE; + } + jdate = GregorianToSdn(ta->tm_year+1900, ta->tm_mon+1, ta->tm_mday); - RETURN_LONG(jdate); } /* }}} */ http://cvs.php.net/viewvc.cgi/php-src/ext/date/php_date.c?r1=1.139&r2=1.140&diff_format=u Index: php-src/ext/date/php_date.c diff -u php-src/ext/date/php_date.c:1.139 php-src/ext/date/php_date.c:1.140 --- php-src/ext/date/php_date.c:1.139 Thu Jun 7 02:21:55 2007 +++ php-src/ext/date/php_date.c Thu Jun 7 08:46:32 2007 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_date.c,v 1.139 2007/06/07 02:21:55 iliaa Exp $ */ +/* $Id: php_date.c,v 1.140 2007/06/07 08:46:32 tony2001 Exp $ */ #include "php.h" #include "php_streams.h" @@ -583,16 +583,18 @@ { struct tm *ta, tmbuf; time_t the_time; - char *tzid; + char *tzid = NULL; the_time = time(NULL); ta = php_localtime_r(&the_time, &tmbuf); - tzid = timelib_timezone_id_from_abbr(ta->tm_zone, ta->tm_gmtoff, ta->tm_isdst); + if (ta) { + tzid = timelib_timezone_id_from_abbr(ta->tm_zone, ta->tm_gmtoff, ta->tm_isdst); + } if (! tzid) { tzid = "UTC"; } - php_error_docref(NULL TSRMLS_CC, E_STRICT, DATE_TZ_ERRMSG "We selected '%s' for '%s/%.1f/%s' instead", tzid, ta->tm_zone, (float) (ta->tm_gmtoff / 3600), ta->tm_isdst ? "DST" : "no DST"); + php_error_docref(NULL TSRMLS_CC, E_STRICT, DATE_TZ_ERRMSG "We selected '%s' for '%s/%.1f/%s' instead", tzid, ta ? ta->tm_zone : "Unknown", ta ? (float) (ta->tm_gmtoff / 3600) : 0, ta ? (ta->tm_isdst ? "DST" : "no DST") : "Unknown"); return tzid; } #endif http://cvs.php.net/viewvc.cgi/php-src/ext/mime_magic/mime_magic.c?r1=1.56&r2=1.57&diff_format=u Index: php-src/ext/mime_magic/mime_magic.c diff -u php-src/ext/mime_magic/mime_magic.c:1.56 php-src/ext/mime_magic/mime_magic.c:1.57 --- php-src/ext/mime_magic/mime_magic.c:1.56 Mon May 28 23:33:13 2007 +++ php-src/ext/mime_magic/mime_magic.c Thu Jun 7 08:46:32 2007 @@ -15,7 +15,7 @@ | Author: Hartmut Holzgraefe <[EMAIL PROTECTED]> | +----------------------------------------------------------------------+ - $Id: mime_magic.c,v 1.56 2007/05/28 23:33:13 iliaa Exp $ + $Id: mime_magic.c,v 1.57 2007/06/07 08:46:32 tony2001 Exp $ This module contains a lot of stuff taken from Apache mod_mime_magic, so the license section is a little bit longer than usual: @@ -1764,6 +1764,9 @@ { char ctimebuf[52]; pp = php_ctime_r((time_t *) &p->l, ctimebuf); + if (!pp) { + return; + } if ((rt = strchr(pp, '\n')) != NULL) { *rt = '\0'; } http://cvs.php.net/viewvc.cgi/php-src/main/main.c?r1=1.728&r2=1.729&diff_format=u Index: php-src/main/main.c diff -u php-src/main/main.c:1.728 php-src/main/main.c:1.729 --- php-src/main/main.c:1.728 Thu Apr 26 09:39:03 2007 +++ php-src/main/main.c Thu Jun 7 08:46:32 2007 @@ -18,7 +18,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: main.c,v 1.728 2007/04/26 09:39:03 tony2001 Exp $ */ +/* $Id: main.c,v 1.729 2007/06/07 08:46:32 tony2001 Exp $ */ /* {{{ includes */ @@ -1132,8 +1132,12 @@ time(&curtime); ta = php_localtime_r(&curtime, &tmbuf); datetime_str = php_asctime_r(ta, asctimebuf); - datetime_str[strlen(datetime_str)-1]=0; /* get rid of the trailing newline */ - snprintf(memory_leak_buf, sizeof(memory_leak_buf), "[%s] Script: '%s'\n", datetime_str, SAFE_FILENAME(SG(request_info).path_translated)); + if (datetime_str) { + datetime_str[strlen(datetime_str)-1]=0; /* get rid of the trailing newline */ + snprintf(memory_leak_buf, sizeof(memory_leak_buf), "[%s] Script: '%s'\n", datetime_str, SAFE_FILENAME(SG(request_info).path_translated)); + } else { + snprintf(memory_leak_buf, sizeof(memory_leak_buf), "[null] Script: '%s'\n", SAFE_FILENAME(SG(request_info).path_translated)); + } # if defined(PHP_WIN32) OutputDebugString(memory_leak_buf); # else
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php