Skip to content

Commit

Permalink
Merge pull request #406 from timopollmeier/duplicate-preference-fix-m…
Browse files Browse the repository at this point in the history
…aster

Check if NVT preferences exist before inserting
  • Loading branch information
mattmundell authored Feb 19, 2019
2 parents bf0d223 + 8f66c1c commit cc8f3bb
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions src/manage_sql.c
Original file line number Diff line number Diff line change
Expand Up @@ -41031,9 +41031,22 @@ manage_nvt_preference_add (const char* name, const char* value)
gchar* quoted_value = sql_quote (value);

if (strcmp (name, "port_range"))
sql ("INSERT into nvt_preferences (name, value)"
" VALUES ('%s', '%s');",
quoted_name, quoted_value);
{
if (sql_int ("SELECT EXISTS"
" (SELECT * FROM nvt_preferences"
" WHERE name = '%s')",
quoted_name))
{
g_warning ("%s: preference '%s' already exists",
__FUNCTION__, name);
}
else
{
sql ("INSERT into nvt_preferences (name, value)"
" VALUES ('%s', '%s');",
quoted_name, quoted_value);
}
}

g_free (quoted_name);
g_free (quoted_value);
Expand Down

0 comments on commit cc8f3bb

Please sign in to comment.