From efad960fabacbddc43e4f7ced3d266006141ee96 Mon Sep 17 00:00:00 2001 From: Jan-Oliver Wagner Date: Wed, 28 Aug 2019 19:37:39 +0200 Subject: [PATCH] Directly store the nvti tags string into the db. Since the timestamps do not appear anymore in the tags string, there is no need to parse them out of the tags string. Now the tags string can simply directly be inserted into the database as is. --- src/manage_sql_nvts.c | 53 +------------------------------------------ 1 file changed, 1 insertion(+), 52 deletions(-) diff --git a/src/manage_sql_nvts.c b/src/manage_sql_nvts.c index da937980b..ec2568f62 100644 --- a/src/manage_sql_nvts.c +++ b/src/manage_sql_nvts.c @@ -215,58 +215,7 @@ insert_nvt (const nvti_t *nvti) quoted_detection = sql_quote (nvti_detection (nvti) ? nvti_detection (nvti) : ""); - if (nvti_tag (nvti)) - { - gchar **split, **point; - GString *tag; - - /* creation_date=2009-04-09 14:18:58 +0200 (Thu, 09 Apr 2009)|... */ - - split = g_strsplit (nvti_tag (nvti), "|", 0); - point = split; - - while (*point) - { - if (((strlen (*point) > strlen ("creation_date")) - && (strncmp (*point, "creation_date", strlen ("creation_date")) - == 0) - && ((*point)[strlen ("creation_date")] == '=')) - || ((strlen (*point) > strlen ("last_modification")) - && (strncmp (*point, "last_modification", - strlen ("last_modification")) - == 0) - && ((*point)[strlen ("last_modification")] == '='))) - { - gchar **move; - move = point; - g_free (*point); - while (*move) - { - move[0] = move[1]; - move++; - } - } - else - point++; - } - - point = split; - tag = g_string_new (""); - while (*point) - { - if (point[1]) - g_string_append_printf (tag, "%s|", *point); - else - g_string_append_printf (tag, "%s", *point); - point++; - } - g_strfreev (split); - - quoted_tag = sql_quote (tag->str); - g_string_free (tag, TRUE); - } - else - quoted_tag = g_strdup (""); + quoted_tag = sql_quote (nvti_tag (nvti) ? nvti_tag (nvti) : ""); quoted_cvss_base = sql_quote (nvti_cvss_base (nvti) ? nvti_cvss_base (nvti) : "");