Skip to content

Commit

Permalink
Merge pull request #1430 from greenbone/mergify/bp/master/pr-1429
Browse files Browse the repository at this point in the history
Fix SQL escaping when adding VT references (bp #1429)
  • Loading branch information
timopollmeier authored Feb 26, 2021
2 parents a36dd25 + 83727f8 commit 77ea127
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,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

Expand Down
6 changes: 4 additions & 2 deletions src/manage_sql_nvts.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit 77ea127

Please sign in to comment.