Skip to content

Commit

Permalink
Fix: Rollback on create_credential privkey error
Browse files Browse the repository at this point in the history
If the private key checks in create_credential fail, the SQL
transaction is now rolled back.

This fixes SQL transaction errors and possible incomplete
credentials being created if there are multiple GMP commands per
connection and one of them is create_credential failing because of
the private key.
  • Loading branch information
timopollmeier committed Nov 22, 2024
1 parent 25d41de commit a1e1df0
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/manage_sql.c
Original file line number Diff line number Diff line change
Expand Up @@ -35916,7 +35916,10 @@ create_credential (const char* name, const char* comment, const char* login,
if (key_private)
key_private_truncated = truncate_private_key (key_private);
else
return 3;
{
sql_rollback ();
return 3;
}

generated_key_public = gvm_ssh_public_from_private
(key_private_truncated
Expand All @@ -35926,6 +35929,7 @@ create_credential (const char* name, const char* comment, const char* login,
if (generated_key_public == NULL)
{
g_free (key_private_truncated);
sql_rollback ();
return 3;
}
g_free (generated_key_public);
Expand Down

0 comments on commit a1e1df0

Please sign in to comment.