tony2001 Thu Jun 7 08:44:41 2007 UTC
Modified files: (Branch: PHP_5_2)
/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:
MFH: check return value of *time_r() functions for NULL
http://cvs.php.net/viewvc.cgi/php-src/ext/calendar/cal_unix.c?r1=1.17.2.2.2.1&r2=1.17.2.2.2.2&diff_format=u
Index: php-src/ext/calendar/cal_unix.c
diff -u php-src/ext/calendar/cal_unix.c:1.17.2.2.2.1
php-src/ext/calendar/cal_unix.c:1.17.2.2.2.2
--- php-src/ext/calendar/cal_unix.c:1.17.2.2.2.1 Mon Jan 1 09:35:48 2007
+++ php-src/ext/calendar/cal_unix.c Thu Jun 7 08:44:40 2007
@@ -50,6 +50,10 @@
}
ta = php_localtime_r(&t, &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.43.2.45.2.48&r2=1.43.2.45.2.49&diff_format=u
Index: php-src/ext/date/php_date.c
diff -u php-src/ext/date/php_date.c:1.43.2.45.2.48
php-src/ext/date/php_date.c:1.43.2.45.2.49
--- php-src/ext/date/php_date.c:1.43.2.45.2.48 Thu Jun 7 02:21:26 2007
+++ php-src/ext/date/php_date.c Thu Jun 7 08:44:40 2007
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_date.c,v 1.43.2.45.2.48 2007/06/07 02:21:26 iliaa Exp $ */
+/* $Id: php_date.c,v 1.43.2.45.2.49 2007/06/07 08:44:40 tony2001 Exp $ */
#include "php.h"
#include "php_streams.h"
@@ -578,16 +578,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.42.2.5.2.6&r2=1.42.2.5.2.7&diff_format=u
Index: php-src/ext/mime_magic/mime_magic.c
diff -u php-src/ext/mime_magic/mime_magic.c:1.42.2.5.2.6
php-src/ext/mime_magic/mime_magic.c:1.42.2.5.2.7
--- php-src/ext/mime_magic/mime_magic.c:1.42.2.5.2.6 Thu Feb 15 00:05:42 2007
+++ php-src/ext/mime_magic/mime_magic.c Thu Jun 7 08:44:41 2007
@@ -15,7 +15,7 @@
| Author: Hartmut Holzgraefe <[EMAIL PROTECTED]> |
+----------------------------------------------------------------------+
- $Id: mime_magic.c,v 1.42.2.5.2.6 2007/02/15 00:05:42 iliaa Exp $
+ $Id: mime_magic.c,v 1.42.2.5.2.7 2007/06/07 08:44:41 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.640.2.23.2.35&r2=1.640.2.23.2.36&diff_format=u
Index: php-src/main/main.c
diff -u php-src/main/main.c:1.640.2.23.2.35 php-src/main/main.c:1.640.2.23.2.36
--- php-src/main/main.c:1.640.2.23.2.35 Wed Apr 18 09:38:56 2007
+++ php-src/main/main.c Thu Jun 7 08:44:41 2007
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: main.c,v 1.640.2.23.2.35 2007/04/18 09:38:56 rrichards Exp $ */
+/* $Id: main.c,v 1.640.2.23.2.36 2007/06/07 08:44:41 tony2001 Exp $ */
/* {{{ includes
*/
@@ -1021,8 +1021,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