Skip to content

Commit

Permalink
Fix: Now the CPE dictionary is no longer continuously parsed again if…
Browse files Browse the repository at this point in the history
… the dictionary is corrupt.

Merge pull request #2127 from greenbone/GEA-419_gvmd_keeps_parsing_corrupt_CPE_dictionary
  • Loading branch information
jhelmold authored Jan 19, 2024
2 parents 852df54 + de7c17e commit 65aae8f
Showing 1 changed file with 35 additions and 30 deletions.
65 changes: 35 additions & 30 deletions src/manage_sql_secinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -3062,7 +3062,7 @@ check_cert_db_version ()
*
* @return 0 success, -1 error.
*/
static int
static void
update_cert_timestamp ()
{
GError *error;
Expand All @@ -3082,7 +3082,7 @@ update_cert_timestamp ()
g_warning ("%s: Failed to get timestamp: %s",
__func__,
error->message);
return -1;
stamp = time(NULL);
}
}
else
Expand All @@ -3093,22 +3093,22 @@ update_cert_timestamp ()
__func__,
timestamp);
g_free (timestamp);
return -1;
stamp = time(NULL);
}
else
{
timestamp[8] = '\0';
g_debug ("%s: parsing: %s", __func__, timestamp);
stamp = parse_feed_timestamp (timestamp);
g_free (timestamp);
if (stamp == 0)
stamp = time(NULL);
}

timestamp[8] = '\0';
g_debug ("%s: parsing: %s", __func__, timestamp);
stamp = parse_feed_timestamp (timestamp);
g_free (timestamp);
if (stamp == 0)
return -1;
}

g_debug ("%s: setting last_update: %lld", __func__, (long long) stamp);
sql ("UPDATE cert.meta SET value = '%lld' WHERE name = 'last_update';",
(long long) stamp);

return 0;
}

/**
Expand Down Expand Up @@ -3276,14 +3276,14 @@ sync_cert ()

g_debug ("%s: update timestamp", __func__);

if (update_cert_timestamp ())
goto fail;
update_cert_timestamp ();

g_info ("%s: Updating CERT info succeeded.", __func__);

return 0;

fail:
update_cert_timestamp ();
return -1;
}

Expand Down Expand Up @@ -3333,7 +3333,7 @@ check_scap_db_version ()
*
* @return 0 success, -1 error.
*/
static int
static void
update_scap_timestamp ()
{
GError *error;
Expand All @@ -3353,7 +3353,7 @@ update_scap_timestamp ()
g_warning ("%s: Failed to get timestamp: %s",
__func__,
error->message);
return -1;
stamp = time(NULL);
}
}
else
Expand All @@ -3364,22 +3364,22 @@ update_scap_timestamp ()
__func__,
timestamp);
g_free (timestamp);
return -1;
stamp = time(NULL);
}
else
{
timestamp[8] = '\0';
g_debug ("%s: parsing: %s", __func__, timestamp);
stamp = parse_feed_timestamp (timestamp);
g_free (timestamp);
if (stamp == 0)
stamp = time(NULL);
}

timestamp[8] = '\0';
g_debug ("%s: parsing: %s", __func__, timestamp);
stamp = parse_feed_timestamp (timestamp);
g_free (timestamp);
if (stamp == 0)
return -1;
}

g_debug ("%s: setting last_update: %lld", __func__, (long long) stamp);
sql ("UPDATE scap2.meta SET value = '%lld' WHERE name = 'last_update';",
(long long) stamp);

return 0;
}

/**
Expand Down Expand Up @@ -3436,8 +3436,7 @@ update_scap_end ()

g_debug ("%s: update timestamp", __func__);

if (update_scap_timestamp ())
return -1;
update_scap_timestamp ();

/* Replace the real scap schema with the new one. */

Expand Down Expand Up @@ -3657,13 +3656,19 @@ update_scap (gboolean reset_scap_db)
setproctitle ("Syncing SCAP: Updating CPEs");

if (update_scap_cpes () == -1)
return -1;
{
update_scap_timestamp ();
return -1;
}

g_debug ("%s: update cves", __func__);
setproctitle ("Syncing SCAP: Updating CVEs");

if (update_scap_cves () == -1)
return -1;
{
update_scap_timestamp ();
return -1;
}

g_debug ("%s: updating user defined data", __func__);

Expand Down

0 comments on commit 65aae8f

Please sign in to comment.