]> granicus.if.org Git - php/commitdiff
MFH: php_gmtime_r() fixes
authorAntony Dovgal <tony2001@php.net>
Thu, 7 Jun 2007 08:59:00 +0000 (08:59 +0000)
committerAntony Dovgal <tony2001@php.net>
Thu, 7 Jun 2007 08:59:00 +0000 (08:59 +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 b6fd56bdb0253399a22b439c9d7641ec1cea5659..0ad8bdb5d379752ecad85eab47b0240392d9346b 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 e6bc6105d072e1025232367b5ecd578bd26e27ee..04a24ce3c81311ca5f875f933f085333cef7f404 100644 (file)
@@ -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");
index 514817ed80283b65fa87d42058948bbb85ee1f46..b249f3a758091a505ff52126097e79447836e97f 100644 (file)
@@ -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, 
index 592e5a352380a28f795ba1391dd2aeec0d490a8e..123d080ff5309c078f011ea9073eeaaac9aaec30 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 b6bc45ca1bc14411f6878fe172fb97128914fd7a..7fe6f8f3758662edccafb0d3474b796230fdf144 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 */