felipe          Wed Sep 10 00:09:04 2008 UTC

  Added files:                 (Branch: PHP_5_2)
    /php-src/ext/xmlrpc/tests   bug18916.phpt bug45226.phpt 

  Modified files:              
    /php-src/ext/xmlrpc/libxmlrpc       xmlrpc.c 
  Log:
  MFH:
  - Merged fix from SF project (Import Jeff Lawsons patches for XML datetime 
bug fixes)
    Fixed bugs:
    #45226 (xmlrpc_set_type() segfaults with valid ISO8601 date string)
    #18916 (xmlrpc_set_type() "not working")
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/xmlrpc/libxmlrpc/xmlrpc.c?r1=1.8.4.3&r2=1.8.4.4&diff_format=u
Index: php-src/ext/xmlrpc/libxmlrpc/xmlrpc.c
diff -u php-src/ext/xmlrpc/libxmlrpc/xmlrpc.c:1.8.4.3 
php-src/ext/xmlrpc/libxmlrpc/xmlrpc.c:1.8.4.4
--- php-src/ext/xmlrpc/libxmlrpc/xmlrpc.c:1.8.4.3       Tue Sep 18 19:49:53 2007
+++ php-src/ext/xmlrpc/libxmlrpc/xmlrpc.c       Wed Sep 10 00:09:04 2008
@@ -31,7 +31,7 @@
 */
 
 
-static const char rcsid[] = "#(@) $Id: xmlrpc.c,v 1.8.4.3 2007/09/18 19:49:53 
iliaa Exp $";
+static const char rcsid[] = "#(@) $Id: xmlrpc.c,v 1.8.4.4 2008/09/10 00:09:04 
felipe Exp $";
 
 
 /****h* ABOUT/xmlrpc
@@ -43,6 +43,13 @@
  *   9/1999 - 10/2000
  * HISTORY
  *   $Log: xmlrpc.c,v $
+ *   Revision 1.8.4.4  2008/09/10 00:09:04  felipe
+ *   MFH:
+ *   - Merged fix from SF project (Import Jeff Lawsons patches for XML 
datetime bug fixes)
+ *     Fixed bugs:
+ *     #45226 (xmlrpc_set_type() segfaults with valid ISO8601 date string)
+ *     #18916 (xmlrpc_set_type() "not working")
+ *
  *   Revision 1.8.4.3  2007/09/18 19:49:53  iliaa
  *
  *   Fixed bug #42189 (xmlrpc_set_type() crashes php on invalid datetime
@@ -166,11 +173,21 @@
 * Begin Time Functions *
 ***********************/
 
+static time_t mkgmtime(struct tm *tm)
+{
+    static const int mdays[12] = {0,31,59,90,120,151,181,212,243,273,304,334};
+
+    return ((((((tm->tm_year - 70) * 365) + mdays[tm->tm_mon] + tm->tm_mday-1 +
+                  (tm->tm_year-68-1+(tm->tm_mon>=2))/4) * 24) + tm->tm_hour) * 
60 +
+        tm->tm_min) * 60 + tm->tm_sec;
+}
+
 static int date_from_ISO8601 (const char *text, time_t * value) {
    struct tm tm;
    int n;
    int i;
-       char buf[18];
+   char buf[30];
+       
 
        if (strchr (text, '-')) {
                char *p = (char *) text, *p2 = buf;
@@ -178,6 +195,9 @@
                        if (*p != '-') {
                                *p2 = *p;
                                p2++;
+                               if (p2-buf >= sizeof(buf)) {
+                                       return -1;
+                               }
                        }
                        p++;
                }
@@ -187,10 +207,6 @@
 
    tm.tm_isdst = -1;
 
-   if(strlen(text) < 17) {
-      return -1;
-   }
-
 #define XMLRPC_IS_NUMBER(x) if (x < '0' || x > '9') return -1;
 
    n = 1000;
@@ -243,7 +259,7 @@
 
    tm.tm_year -= 1900;
 
-   *value = mktime(&tm);
+   *value = mkgmtime(&tm);
 
    return 0;
 
@@ -251,14 +267,14 @@
 
 static int date_to_ISO8601 (time_t value, char *buf, int length) {
    struct tm *tm, tmbuf;
-   tm = php_localtime_r(&value, &tmbuf);
+   tm = php_gmtime_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
-   return strftime(buf, length, "%Y%m%dT%H:%M:%S", tm);
+   return strftime(buf, length, "%Y%m%dT%H:%M:%SZ", tm);
 #endif
 }
 
@@ -1529,8 +1545,7 @@
       date_to_ISO8601(time, timeBuf, sizeof(timeBuf));
 
       if(timeBuf[0]) {
-         simplestring_clear(&value->str);
-         simplestring_add(&value->str, timeBuf);
+         XMLRPC_SetValueDateTime_ISO8601 (value, timeBuf);
       }
    }
 }
@@ -1706,8 +1721,11 @@
    if(value) {
       time_t time_val = 0;
       if(s) {
+         value->type = xmlrpc_datetime;
          date_from_ISO8601(s, &time_val);
-         XMLRPC_SetValueDateTime(value, time_val);
+         value->i = time_val;
+         simplestring_clear(&value->str);
+         simplestring_add(&value->str, s);
       }
    }
 }

http://cvs.php.net/viewvc.cgi/php-src/ext/xmlrpc/tests/bug18916.phpt?view=markup&rev=1.1
Index: php-src/ext/xmlrpc/tests/bug18916.phpt
+++ php-src/ext/xmlrpc/tests/bug18916.phpt

http://cvs.php.net/viewvc.cgi/php-src/ext/xmlrpc/tests/bug45226.phpt?view=markup&rev=1.1
Index: php-src/ext/xmlrpc/tests/bug45226.phpt
+++ php-src/ext/xmlrpc/tests/bug45226.phpt



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to