diff --git a/CHANGELOG.md b/CHANGELOG.md index ad95c7089..fbefc76ae 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -59,6 +59,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ### Fixed - Also create owner WITH clause for single resources [#1406](https://github.com/greenbone/gvmd/pull/1406) +- Fix SQL escaping when adding VT references [#1429](https://github.com/greenbone/gvmd/pull/1429) ### Removed diff --git a/src/manage_sql_nvts.c b/src/manage_sql_nvts.c index 79a5aa049..94787b239 100644 --- a/src/manage_sql_nvts.c +++ b/src/manage_sql_nvts.c @@ -329,16 +329,18 @@ insert_nvt (const nvti_t *nvti) for (i = 0; i < nvti_vtref_len (nvti); i++) { vtref_t *ref; - gchar *quoted_id, *quoted_text; + gchar *quoted_type, *quoted_id, *quoted_text; ref = nvti_vtref (nvti, i); + quoted_type = sql_quote (vtref_type (ref)); quoted_id = sql_quote (vtref_id (ref)); quoted_text = sql_quote (vtref_text (ref) ? vtref_text (ref) : ""); sql ("INSERT into vt_refs (vt_oid, type, ref_id, ref_text)" " VALUES ('%s', '%s', '%s', '%s');", - nvti_oid (nvti), vtref_type (ref), quoted_id, quoted_text); + nvti_oid (nvti), quoted_type, quoted_id, quoted_text); + g_free (quoted_type); g_free (quoted_id); g_free (quoted_text); }