diff options
author | Antony Dovgal <tony2001@php.net> | 2007-06-07 08:59:00 +0000 |
---|---|---|
committer | Antony Dovgal <tony2001@php.net> | 2007-06-07 08:59:00 +0000 |
commit | d042fd067569aac8970428629309d9b1110bbbcc (patch) | |
tree | 73feee9ae22642eb7454420018929b8dc6687462 | |
parent | c9805e7b9240c9513c4fb6add41b004328caf463 (diff) | |
download | php-git-d042fd067569aac8970428629309d9b1110bbbcc.tar.gz |
MFH: php_gmtime_r() fixes
-rw-r--r-- | ext/ftp/ftp.c | 3 | ||||
-rw-r--r-- | ext/interbase/ibase_query.c | 6 | ||||
-rw-r--r-- | ext/session/session.c | 9 | ||||
-rw-r--r-- | ext/standard/datetime.c | 6 | ||||
-rw-r--r-- | ext/standard/ftp_fopen_wrapper.c | 3 |
5 files changed, 24 insertions, 3 deletions
diff --git a/ext/ftp/ftp.c b/ext/ftp/ftp.c index b6fd56bdb0..0ad8bdb5d3 100644 --- a/ext/ftp/ftp.c +++ b/ext/ftp/ftp.c @@ -1012,6 +1012,9 @@ ftp_mdtm(ftpbuf_t *ftp, const char *path) /* figure out the GMT offset */ stamp = time(NULL); gmt = php_gmtime_r(&stamp, &tmbuf); + if (!gmt) { + return -1; + } gmt->tm_isdst = -1; /* apply the GMT offset */ diff --git a/ext/interbase/ibase_query.c b/ext/interbase/ibase_query.c index e6bc6105d0..04a24ce3c8 100644 --- a/ext/interbase/ibase_query.c +++ b/ext/interbase/ibase_query.c @@ -674,7 +674,11 @@ static int _php_ibase_bind(XSQLDA *sqlda, zval ***b_vars, BIND_BUF *buf, /* {{{ case SQL_TYPE_DATE: case SQL_TYPE_TIME: if (Z_TYPE_P(b_var) == IS_LONG) { - php_gmtime_r(&Z_LVAL_P(b_var), &t); + struct tm *res; + res = php_gmtime_r(&Z_LVAL_P(b_var), &t); + if (!res) { + return FAILURE; + } } else { #ifdef HAVE_STRPTIME char *format = INI_STR("ibase.timestampformat"); diff --git a/ext/session/session.c b/ext/session/session.c index 514817ed80..b249f3a758 100644 --- a/ext/session/session.c +++ b/ext/session/session.c @@ -946,10 +946,15 @@ static char *week_days[] = { static void strcpy_gmt(char *ubuf, time_t *when) { char buf[MAX_STR]; - struct tm tm; + struct tm tm, *res; int n; - php_gmtime_r(when, &tm); + res = php_gmtime_r(when, &tm); + + if (!res) { + buf[0] = '\0'; + return; + } n = slprintf(buf, sizeof(buf), "%s, %02d %s %d %02d:%02d:%02d GMT", /* SAFE */ week_days[tm.tm_wday], tm.tm_mday, diff --git a/ext/standard/datetime.c b/ext/standard/datetime.c index 592e5a3523..123d080ff5 100644 --- a/ext/standard/datetime.c +++ b/ext/standard/datetime.c @@ -58,6 +58,12 @@ PHPAPI char *php_std_date(time_t t TSRMLS_DC) tm1 = php_gmtime_r(&t, &tmbuf); str = emalloc(81); + str[0] = '\0'; + + if (!tm1) { + return str; + } + if (PG(y2k_compliance)) { snprintf(str, 80, "%s, %02d %s %04d %02d:%02d:%02d GMT", day_short_names[tm1->tm_wday], diff --git a/ext/standard/ftp_fopen_wrapper.c b/ext/standard/ftp_fopen_wrapper.c index b6bc45ca1b..7fe6f8f375 100644 --- a/ext/standard/ftp_fopen_wrapper.c +++ b/ext/standard/ftp_fopen_wrapper.c @@ -808,6 +808,9 @@ static int php_stream_ftp_url_stat(php_stream_wrapper *wrapper, char *url, int f /* figure out the GMT offset */ stamp = time(NULL); gmt = php_gmtime_r(&stamp, &tmbuf); + if (!gmt) { + goto mdtm_error; + } gmt->tm_isdst = -1; /* apply the GMT offset */ |