From f1f0deae4cbfa8006536481359f52dd308e15d95 Mon Sep 17 00:00:00 2001 From: Antony Dovgal Date: Thu, 7 Jun 2007 09:07:12 +0000 Subject: [PATCH] php_localtime_r() checks --- ext/calendar/easter.c | 10 +++++++--- ext/pdo_sqlite/sqlite/src/date.c | 6 ++++-- ext/sqlite/libsqlite/src/date.c | 3 +++ ext/standard/info.c | 2 +- ext/xmlrpc/libxmlrpc/xmlrpc.c | 6 ++++++ 5 files changed, 21 insertions(+), 6 deletions(-) diff --git a/ext/calendar/easter.c b/ext/calendar/easter.c index 6329986e4a..ed28931ae0 100644 --- a/ext/calendar/easter.c +++ b/ext/calendar/easter.c @@ -36,10 +36,14 @@ static void _cal_easter(INTERNAL_FUNCTION_PARAMETERS, int gm) /* Default to the current year if year parameter is not given */ { time_t a; - struct tm b; + struct tm b, *res; time(&a); - php_localtime_r(&a, &b); - year = 1900 + b.tm_year; + res = php_localtime_r(&a, &b); + if (!res) { + year = 1900; + } else { + year = 1900 + b.tm_year; + } } if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, diff --git a/ext/pdo_sqlite/sqlite/src/date.c b/ext/pdo_sqlite/sqlite/src/date.c index 68d17a7013..10633e9afe 100644 --- a/ext/pdo_sqlite/sqlite/src/date.c +++ b/ext/pdo_sqlite/sqlite/src/date.c @@ -415,8 +415,10 @@ static double localtimeOffset(DateTime *p){ computeJD(&x); t = (x.rJD-2440587.5)*86400.0 + 0.5; sqlite3OsEnterMutex(); - pTm = php_localtime_r -(&t, &tmbuf); + pTm = php_localtime_r(&t, &tmbuf); + if (!pTm) { + return 0; + } y.Y = pTm->tm_year + 1900; y.M = pTm->tm_mon + 1; y.D = pTm->tm_mday; diff --git a/ext/sqlite/libsqlite/src/date.c b/ext/sqlite/libsqlite/src/date.c index f994e0769f..9ea9c5a77b 100644 --- a/ext/sqlite/libsqlite/src/date.c +++ b/ext/sqlite/libsqlite/src/date.c @@ -418,6 +418,9 @@ static double localtimeOffset(DateTime *p){ t = (x.rJD-2440587.5)*86400.0 + 0.5; sqliteOsEnterMutex(); pTm = php_localtime_r(&t, &tmbuf); + if (!pTm) { + return 0; + } y.Y = pTm->tm_year + 1900; y.M = pTm->tm_mon + 1; y.D = pTm->tm_mday; diff --git a/ext/standard/info.c b/ext/standard/info.c index b4be6890dc..2c9809051d 100644 --- a/ext/standard/info.c +++ b/ext/standard/info.c @@ -1002,7 +1002,7 @@ PHPAPI char *php_logo_guid() the_time = time(NULL); ta = php_localtime_r(&the_time, &tmbuf); - if ((ta->tm_mon==3) && (ta->tm_mday==1)) { + if (ta && (ta->tm_mon==3) && (ta->tm_mday==1)) { logo_guid = PHP_EGG_LOGO_GUID; } else { logo_guid = PHP_LOGO_GUID; diff --git a/ext/xmlrpc/libxmlrpc/xmlrpc.c b/ext/xmlrpc/libxmlrpc/xmlrpc.c index 555ffae22c..3c192d93f6 100644 --- a/ext/xmlrpc/libxmlrpc/xmlrpc.c +++ b/ext/xmlrpc/libxmlrpc/xmlrpc.c @@ -43,6 +43,9 @@ static const char rcsid[] = "#(@) $Id$"; * 9/1999 - 10/2000 * HISTORY * $Log$ + * Revision 1.10 2007/01/01 09:29:33 sebastian + * Bump year. + * * Revision 1.9 2007/11/30 16:38:53 iliaa * zts fixes * @@ -236,6 +239,9 @@ static int date_from_ISO8601 (const char *text, time_t * value) { static int date_to_ISO8601 (time_t value, char *buf, int length) { struct tm *tm, tmbuf; tm = php_localtime_r(&value, &tmbuf); + if (!tm) { + return 0; + } #if 0 /* TODO: soap seems to favor this method. xmlrpc the latter. */ return strftime (buf, length, "%Y-%m-%dT%H:%M:%SZ", tm); #else -- 2.50.1