]> git.sur5r.net Git - openldap/commitdiff
Fix lutil_parsetime parsing fractional seconds
authorHoward Chu <hyc@openldap.org>
Fri, 28 Apr 2006 01:26:05 +0000 (01:26 +0000)
committerHoward Chu <hyc@openldap.org>
Fri, 28 Apr 2006 01:26:05 +0000 (01:26 +0000)
libraries/liblutil/utils.c

index 0da7df479071f1cd4cfe7d6de3d2ba977aba10c6..c7ae35cd122a6e89de0421810baf8619a4782fbd 100644 (file)
@@ -247,14 +247,17 @@ int lutil_parsetime( char *atm, struct lutil_tm *tm )
                if (tm->tm_sec < 0 || tm->tm_sec > 61) break;
 
                /* Fractions of seconds */
-               for (i = 0, fracs = 0; isdigit((unsigned char) *ptr); ) {
-                       i*=10; i+= *ptr++ - '0';
-                       fracs++;
-               }
-               tm->tm_usec = i;
-               if (i) {
-                       for (i = fracs; i<6; i++)
-                               tm->tm_usec *= 10;
+               if ( *ptr == '.' ) {
+                       ptr++;
+                       for (i = 0, fracs = 0; isdigit((unsigned char) *ptr); ) {
+                               i*=10; i+= *ptr++ - '0';
+                               fracs++;
+                       }
+                       tm->tm_usec = i;
+                       if (i) {
+                               for (i = fracs; i<6; i++)
+                                       tm->tm_usec *= 10;
+                       }
                }
 
                /* Must be UTC */