]> granicus.if.org Git - php/commitdiff
php_gmtime_r() fixes
authorAntony Dovgal <tony2001@php.net>
Thu, 7 Jun 2007 08:58:38 +0000 (08:58 +0000)
committerAntony Dovgal <tony2001@php.net>
Thu, 7 Jun 2007 08:58:38 +0000 (08:58 +0000)
ext/ftp/ftp.c
ext/interbase/ibase_query.c
ext/session/session.c
ext/standard/datetime.c
ext/standard/ftp_fopen_wrapper.c

index 80165e85088078b56245f5b19a3ef88faf00eb13..820de4cb301ab5af78b6dd178ba53770a1fbc235 100644 (file)
@@ -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 */
index 73277e15788eaba0af3a0e340d13afea75a8e4e2..2f9ebc8c5aabdc249fadd98df686a0825f2590cb 100644 (file)
@@ -675,7 +675,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");
index 874bbc67d9765025fcecd4110515d2053a89bc0c..93c185d44329e69acaa560506db778537abf788f 100644 (file)
@@ -930,11 +930,16 @@ static char *week_days[] = {
 static inline 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 = snprintf(buf, sizeof(buf), "%s, %02d %s %d %02d:%02d:%02d GMT", /* SAFE */
                                week_days[tm.tm_wday], tm.tm_mday, 
                                month_names[tm.tm_mon], tm.tm_year + 1900, 
index f67ada29f06ee4e6b7eca17c4a0574600620d785..38e64388e2339ab43c03c0c444d9b69beef3eeae 100644 (file)
@@ -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],
index 0a2d818abf0d83539117c13533ba130f95caa0fb..813eecf1feef03bd9434718089b96bfaead3c0f9 100644 (file)
@@ -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 */