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

Fix: Revert "Change: Drop parsing for $Date" #809

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
44 changes: 39 additions & 5 deletions base/nvti.c
Expand Up @@ -300,20 +300,45 @@ parse_nvt_timestamp (const gchar *str_time)
int offset;
struct tm tm;

if (strcmp ((char *) str_time, "") == 0)
return 0;
if ((strcmp ((char *) str_time, "") == 0)
|| (strcmp ((char *) str_time, "$Date: $") == 0)
|| (strcmp ((char *) str_time, "$Date$") == 0)
|| (strcmp ((char *) str_time, "$Date:$") == 0)
|| (strcmp ((char *) str_time, "$Date") == 0)
|| (strcmp ((char *) str_time, "$$") == 0))
{
return 0;
}

/* Parse the time. */

/* 2011-08-09 08:20:34 +0200 (Tue, 09 Aug 2011) */
/* $Date: 2012-02-17 16:05:26 +0100 (Fr, 17. Feb 2012) $ */
/* $Date: Fri, 11 Nov 2011 14:42:28 +0100 $ */
memset (&tm, 0, sizeof (struct tm));
if (strptime ((char *) str_time, "%F %T %z", &tm) == NULL)
{
memset (&tm, 0, sizeof (struct tm));
if (strptime ((char *) str_time, "%a %b %d %T %Y %z", &tm) == NULL)
if (strptime ((char *) str_time, "$Date: %F %T %z", &tm) == NULL)
{
g_warning ("%s: Failed to parse time: %s", __func__, str_time);
return 0;
memset (&tm, 0, sizeof (struct tm));
if (strptime ((char *) str_time, "%a %b %d %T %Y %z", &tm) == NULL)
{
memset (&tm, 0, sizeof (struct tm));
if (strptime ((char *) str_time, "$Date: %a, %d %b %Y %T %z", &tm)
== NULL)
{
memset (&tm, 0, sizeof (struct tm));
if (strptime ((char *) str_time, "$Date: %a %b %d %T %Y %z",
&tm)
== NULL)
{
g_warning ("%s: Failed to parse time: %s", __func__,
str_time);
return 0;
}
}
}
}
}
epoch_time = mktime (&tm);
Expand All @@ -327,8 +352,17 @@ parse_nvt_timestamp (const gchar *str_time)

if ((sscanf ((char *) str_time, "%*u-%*u-%*u %*u:%*u:%*u %d%*[^]]", &offset)
!= 1)
&& (sscanf ((char *) str_time, "$Date: %*u-%*u-%*u %*u:%*u:%*u %d%*[^]]",
&offset)
!= 1)
&& (sscanf ((char *) str_time, "%*s %*s %*s %*u:%*u:%*u %*u %d%*[^]]",
&offset)
!= 1)
&& (sscanf ((char *) str_time,
"$Date: %*s %*s %*s %*u %*u:%*u:%*u %d%*[^]]", &offset)
!= 1)
&& (sscanf ((char *) str_time,
"$Date: %*s %*s %*s %*u:%*u:%*u %*u %d%*[^]]", &offset)
!= 1))
{
g_warning ("%s: Failed to parse timezone offset: %s", __func__, str_time);
Expand Down