Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

md manage:WARNING:2021-07-01 12h58.04 utc:480: parse_iso_time_tz: Could not parse time 2019-01-18T17:29:00+00:00 #1609

Closed
Dexus opened this issue Jul 1, 2021 · 4 comments
Labels
bug Something isn't working

Comments

@Dexus
Copy link
Contributor

Dexus commented Jul 1, 2021

After a fresh install of gvmd 21.4.0 i allways get erros like
md manage:WARNING:2021-07-01 12h58.04 utc:480: parse_iso_time_tz: Could not parse time 2019-01-18T17:29:00+00:00

Expected behavior

parse the date as expected

Actual behavior

It looks like the error makes no problems, but it filled up the logs with to much crap.

Steps to reproduce

  1. fresh install gvmd
  2. run updates
  3. look to the log files

GVM versions

gsa: (gsad --version) 21.4.0

gvm: (gvmd --version) 21.4.0

openvas-scanner: (openvas --version) 21.4.0

gvm-libs: 21.4.0

Environment

Operating system: Alpine Linux / Ubuntu 20.10

Installation method / source: (packages, source installation) source installation

Logfiles

...
md manage:WARNING:2021-07-01 12h58.04 utc:480: parse_iso_time_tz: Could not parse time 2019-01-18T17:29:00+00:00
...
... the line abdove will repeat with different timestamps over 1000 times, so the log will be over 180 MB big after some minutes.
...
@Dexus Dexus added the bug Something isn't working label Jul 1, 2021
@Dexus
Copy link
Contributor Author

Dexus commented Jul 5, 2021

same will also with 21.4.1/2

@fcolista
Copy link
Contributor

A proposed patch that allows buildi on musl-related distribution:

diff --git a/src/manage.c b/src/manage.c
index 7e39631..6edbe65 100644
--- a/src/manage.c
+++ b/src/manage.c
@@ -5788,7 +5788,11 @@ manage_scap_update_time ()
   if (strptime (content, "%Y%m%d%H%M", &update_time))
     {
       static char time_string[100];
-      strftime (time_string, 99, "%FT%T.000%z", &update_time);
+      #if !defined(__GLIBC__)
+        strftime (time_string, 99, "%Y-%m-%dT.000", &update_time);
+      #else
+        strftime (time_string, 99, "%FT%T.000%z", &update_time);
+      #endif
       return time_string;
     }
   return "";
diff --git a/src/manage_sql.c b/src/manage_sql.c
index 14d9e35..768fd79 100644
--- a/src/manage_sql.c
+++ b/src/manage_sql.c
@@ -26202,7 +26202,11 @@ host_summary_append (GString *host_summary_buffer, const char *host,
           struct tm start_tm;
 
           memset (&start_tm, 0, sizeof (struct tm));
-          if (strptime (start_iso, "%FT%H:%M:%S", &start_tm) == NULL)
+          #if !defined(__GLIBC__)
+            if (strptime (start_iso, "%Y-%m-%dT%H:%M:%S", &start_tm) == NULL)
+          #else
+            if (strptime (start_iso, "%FT%H:%M:%S", &start_tm) == NULL)
+          #endif
             {
               g_warning ("%s: Failed to parse start", __func__);
               return;
@@ -26222,7 +26226,11 @@ host_summary_append (GString *host_summary_buffer, const char *host,
           struct tm end_tm;
 
           memset (&end_tm, 0, sizeof (struct tm));
-          if (strptime (end_iso, "%FT%H:%M:%S", &end_tm) == NULL)
+          #if !defined(__GLIBC__)
+            if (strptime (end_iso, "%Y-%m-%dT%H:%M:%S", &end_tm) == NULL)
+          #else
+            if (strptime (end_iso, "%FT%H:%M:%S", &end_tm) == NULL)
+          #endif
             {
               g_warning ("%s: Failed to parse end", __func__);
               return;
diff --git a/src/utils.c b/src/utils.c
index ee5073d..4161406 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -364,20 +364,31 @@ parse_iso_time_tz (const char *text_time, const char *fallback_tz)
                            secs_str && strcmp (secs_str, "")
                             ? secs_str : ":00",
                            offset_str ? offset_str : "");
-
-      if (strptime_with_reset ((char*) cleaned_text_time, "%FT%T%z", &tm))
+      #if !defined(__GLIBC__)
+        if (strptime_with_reset ((char*) cleaned_text_time, "%Y-%m-%dT%T", &tm))
+      #else
+        if (strptime_with_reset ((char*) cleaned_text_time, "%FT%T%z", &tm))
+      #endif
         {
           /* ISO time with numeric offset (e.g. 2020-06-01T01:02:03+04:30) */
           tm.tm_sec = tm.tm_sec - tm.tm_gmtoff;
           tm.tm_gmtoff = 0;
           epoch_time = mktime_with_tz (&tm, "UTC");
         }
-      else if (strptime_with_reset ((char*) cleaned_text_time, "%FT%TZ", &tm))
+      #if !defined(__GLIBC__)
+        else if (strptime_with_reset ((char*) cleaned_text_time, "%Y-%m-%dT%T", &tm))
+      #else
+        else if (strptime_with_reset ((char*) cleaned_text_time, "%FT%TZ", &tm))
+      #endif
         {
           /* ISO time with "Z" for UTC timezone (e.g. 2020-06-01T01:02:03Z) */
           epoch_time = mktime_with_tz (&tm, "UTC");
         }
-      else if (strptime_with_reset ((char*) cleaned_text_time, "%FT%T", &tm))
+      #if !defined(__GLIBC__)
+        else if (strptime_with_reset ((char*) cleaned_text_time, "%Y-%m-%dT%T", &tm))
+      #else
+        else if (strptime_with_reset ((char*) cleaned_text_time, "%FT%T", &tm))
+      #endif
         {
           /* ISO time without timezone suffix (e.g. 2020-06-01T01:02:03) */
           epoch_time = mktime_with_tz (&tm, fallback_tz ? fallback_tz : "UTC");
@@ -427,7 +438,11 @@ iso_time_internal (time_t *epoch_time, const char **abbrev)
   if (timezone == 0)
 #endif
     {
-      if (strftime (time_string, 98, "%FT%TZ", &tm) == 0)
+      #if !defined(__GLIBC__)
+        if (strftime (time_string, 98, "%Y-%m-%dT%T", &tm) == 0)
+      #else
+        if (strftime (time_string, 98, "%FT%TZ", &tm) == 0)
+      #endif
         return NULL;
 
       if (abbrev)
@@ -437,7 +452,11 @@ iso_time_internal (time_t *epoch_time, const char **abbrev)
     {
       int len;
 
-      if (strftime (time_string, 98, "%FT%T%z", &tm) == 0)
+      #if !defined(__GLIBC__)
+        if (strftime (time_string, 98, "%Y-%m-%dT%T", &tm) == 0)
+      #else
+        if (strftime (time_string, 98, "%FT%T%z", &tm) == 0)
+      #endif
         return NULL;
 
       /* Insert the ISO 8601 colon by hand. */

@Dexus do you have a chance to check if it builds on glibc distribution?
Thanks.

.: Francesco

@Dexus
Copy link
Contributor Author

Dexus commented Jul 28, 2021

This looks to work with out all the parse_iso_time messages.

@Dexus
Copy link
Contributor Author

Dexus commented Jul 28, 2021

@fcolista

You have only one Typo:

Corrected version:

diff --git a/src/manage.c b/src/manage.c
index 7e39631..6edbe65 100644
--- a/src/manage.c
+++ b/src/manage.c
@@ -5788,7 +5788,11 @@ manage_scap_update_time ()
   if (strptime (content, "%Y%m%d%H%M", &update_time))
     {
       static char time_string[100];
-      strftime (time_string, 99, "%FT%T.000%z", &update_time);
+      #if !defined(__GLIBC__)
+        strftime (time_string, 99, "%Y-%m-%dT%T.000", &update_time);
+      #else
+        strftime (time_string, 99, "%FT%T.000%z", &update_time);
+      #endif
       return time_string;
     }
   return "";
diff --git a/src/manage_sql.c b/src/manage_sql.c
index 14d9e35..768fd79 100644
--- a/src/manage_sql.c
+++ b/src/manage_sql.c
@@ -26202,7 +26202,11 @@ host_summary_append (GString *host_summary_buffer, const char *host,
           struct tm start_tm;
 
           memset (&start_tm, 0, sizeof (struct tm));
-          if (strptime (start_iso, "%FT%H:%M:%S", &start_tm) == NULL)
+          #if !defined(__GLIBC__)
+            if (strptime (start_iso, "%Y-%m-%dT%H:%M:%S", &start_tm) == NULL)
+          #else
+            if (strptime (start_iso, "%FT%H:%M:%S", &start_tm) == NULL)
+          #endif
             {
               g_warning ("%s: Failed to parse start", __func__);
               return;
@@ -26222,7 +26226,11 @@ host_summary_append (GString *host_summary_buffer, const char *host,
           struct tm end_tm;
 
           memset (&end_tm, 0, sizeof (struct tm));
-          if (strptime (end_iso, "%FT%H:%M:%S", &end_tm) == NULL)
+          #if !defined(__GLIBC__)
+            if (strptime (end_iso, "%Y-%m-%dT%H:%M:%S", &end_tm) == NULL)
+          #else
+            if (strptime (end_iso, "%FT%H:%M:%S", &end_tm) == NULL)
+          #endif
             {
               g_warning ("%s: Failed to parse end", __func__);
               return;
diff --git a/src/utils.c b/src/utils.c
index ee5073d..4161406 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -364,20 +364,31 @@ parse_iso_time_tz (const char *text_time, const char *fallback_tz)
                            secs_str && strcmp (secs_str, "")
                             ? secs_str : ":00",
                            offset_str ? offset_str : "");
-
-      if (strptime_with_reset ((char*) cleaned_text_time, "%FT%T%z", &tm))
+      #if !defined(__GLIBC__)
+        if (strptime_with_reset ((char*) cleaned_text_time, "%Y-%m-%dT%T", &tm))
+      #else
+        if (strptime_with_reset ((char*) cleaned_text_time, "%FT%T%z", &tm))
+      #endif
         {
           /* ISO time with numeric offset (e.g. 2020-06-01T01:02:03+04:30) */
           tm.tm_sec = tm.tm_sec - tm.tm_gmtoff;
           tm.tm_gmtoff = 0;
           epoch_time = mktime_with_tz (&tm, "UTC");
         }
-      else if (strptime_with_reset ((char*) cleaned_text_time, "%FT%TZ", &tm))
+      #if !defined(__GLIBC__)
+        else if (strptime_with_reset ((char*) cleaned_text_time, "%Y-%m-%dT%T", &tm))
+      #else
+        else if (strptime_with_reset ((char*) cleaned_text_time, "%FT%TZ", &tm))
+      #endif
         {
           /* ISO time with "Z" for UTC timezone (e.g. 2020-06-01T01:02:03Z) */
           epoch_time = mktime_with_tz (&tm, "UTC");
         }
-      else if (strptime_with_reset ((char*) cleaned_text_time, "%FT%T", &tm))
+      #if !defined(__GLIBC__)
+        else if (strptime_with_reset ((char*) cleaned_text_time, "%Y-%m-%dT%T", &tm))
+      #else
+        else if (strptime_with_reset ((char*) cleaned_text_time, "%FT%T", &tm))
+      #endif
         {
           /* ISO time without timezone suffix (e.g. 2020-06-01T01:02:03) */
           epoch_time = mktime_with_tz (&tm, fallback_tz ? fallback_tz : "UTC");
@@ -427,7 +438,11 @@ iso_time_internal (time_t *epoch_time, const char **abbrev)
   if (timezone == 0)
 #endif
     {
-      if (strftime (time_string, 98, "%FT%TZ", &tm) == 0)
+      #if !defined(__GLIBC__)
+        if (strftime (time_string, 98, "%Y-%m-%dT%T", &tm) == 0)
+      #else
+        if (strftime (time_string, 98, "%FT%TZ", &tm) == 0)
+      #endif
         return NULL;
 
       if (abbrev)
@@ -437,7 +452,11 @@ iso_time_internal (time_t *epoch_time, const char **abbrev)
     {
       int len;
 
-      if (strftime (time_string, 98, "%FT%T%z", &tm) == 0)
+      #if !defined(__GLIBC__)
+        if (strftime (time_string, 98, "%Y-%m-%dT%T", &tm) == 0)
+      #else
+        if (strftime (time_string, 98, "%FT%T%z", &tm) == 0)
+      #endif
         return NULL;
 
       /* Insert the ISO 8601 colon by hand. */

mergify bot pushed a commit that referenced this issue Jul 29, 2021
This patch fixes the error when parsing the time in a format like:
2019-01-18T17:29:00+00:00  with musl.

This behavior is described in the issue #1609

(cherry picked from commit 30e2c61)
mergify bot pushed a commit that referenced this issue Jul 29, 2021
This patch fixes the error when parsing the time in a format like:
2019-01-18T17:29:00+00:00  with musl.

This behavior is described in the issue #1609

(cherry picked from commit 30e2c61)

# Conflicts:
#	CHANGELOG.md
@Dexus Dexus closed this as completed Jul 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants