Code

frontend/scanner: Pass the right size to strncat.
[sysdb.git] / src / frontend / scanner.l
index f17b689c97a5b98f03a47ac341981ac07e832f66..6781122c3c2b830547b66a0fe82a7e57b3f15cb4 100644 (file)
@@ -210,6 +210,7 @@ time                ([0-9]{1,2}:[0-9]{1,2}(:[0-9]{1,2}(\.[0-9]{1,9})?)?)
                struct tm tm;
                char time[9], ns[10];
                char *tmp;
+               int t;
 
                memset(&tm, 0, sizeof(tm));
                memset(time, '\0', sizeof(time));
@@ -236,7 +237,7 @@ time                ([0-9]{1,2}:[0-9]{1,2}(:[0-9]{1,2}(\.[0-9]{1,9})?)?)
                assert(tmp);
                tmp = strchr(tmp + 1, ':');
                if (! tmp)
-                       strncat(time, ":00", sizeof(time));
+                       strncat(time, ":00", sizeof(time) - strlen(time) - 1);
 
                if (! strptime(time, "%H:%M:%S", &tm)) {
                        char errmsg[1024];
@@ -246,7 +247,8 @@ time                ([0-9]{1,2}:[0-9]{1,2}(:[0-9]{1,2}(\.[0-9]{1,9})?)?)
                        return SCANNER_ERROR;
                }
 
-               yylval->datetime = SECS_TO_SDB_TIME(mktime(&tm));
+               t = tm.tm_sec + 60 * tm.tm_min + 3600 * tm.tm_hour;
+               yylval->datetime = SECS_TO_SDB_TIME(t);
                yylval->datetime += (sdb_time_t)strtoll(ns, NULL, 10);
                return TIME;
        }