Skip to content

Commit

Permalink
Small fixes after Coverity scan
Browse files Browse the repository at this point in the history
  • Loading branch information
paolostivanin committed Mar 1, 2024
1 parent 74601d0 commit 338c81e
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/app.c
Original file line number Diff line number Diff line change
Expand Up @@ -609,6 +609,8 @@ get_db_path (AppData *app_data)
gchar *msg = g_strconcat ("Database file/location:\n<b>", db_path, "</b>\ndoes not exist. A new database will be created.", NULL);
show_message_dialog (app_data->main_window, msg, GTK_MESSAGE_ERROR);
g_free (msg);
g_free (db_path);
db_path = NULL;
goto new_db;
}
goto end;
Expand Down
1 change: 1 addition & 0 deletions src/common/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,7 @@ get_authpro_derived_key (const gchar *password,
salt, AUTHPRO_SALT_TAG,
NULL, 0, NULL, 0) != GPG_ERR_NO_ERROR) {
g_printerr ("Error while opening the KDF handler\n");
gcry_free (derived_key);
return NULL;
}
if (gcry_kdf_compute (hd, NULL) != GPG_ERR_NO_ERROR) {
Expand Down
6 changes: 4 additions & 2 deletions src/common/twofas.c
Original file line number Diff line number Diff line change
Expand Up @@ -340,13 +340,15 @@ decrypt_data (const gchar **b64_data,
gpg_error_t gpg_err = gcry_cipher_decrypt (hd, twofas_data->json_data, enc_buf_size, enc_data, enc_buf_size);
if (gpg_err) {
g_printerr ("Failed to decrypt data: %s/%s\n", gcry_strsource (g_err), gcry_strerror (g_err));
gcry_free (derived_key);
g_free (enc_data);
gcry_cipher_close (hd);
return;
}

gpg_err = gcry_cipher_checktag (hd, tag, TWOFAS_TAG);
if (gpg_err) {
g_printerr ("Failed to verify the tag: %s/%s\n", gcry_strsource (g_err), gcry_strerror (g_err));
// TODO: cleanup
return;
}

gcry_cipher_close (hd);
Expand Down
3 changes: 3 additions & 0 deletions src/exports.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ export_data_cb (GSimpleAction *simple,

if (export_file_abs_path == NULL) {
show_message_dialog (app_data->main_window, "Invalid export file name/path.", GTK_MESSAGE_ERROR);
if (encrypted == TRUE) {
gcry_free (password);
}
return;
}

Expand Down
3 changes: 3 additions & 0 deletions src/new-db-cb.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ new_db (AppData *app_data)
if (app_data->db_data->key == NULL) {
gtk_widget_hide (newdb_diag);
revert_db_path (app_data, old_db_path);
g_string_free (new_db_path_with_suffix, TRUE);
return RETRY_CHANGE;
}
secret_password_store (OTPCLIENT_SCHEMA, SECRET_COLLECTION_DEFAULT, "main_pwd", app_data->db_data->key, NULL, on_password_stored, NULL, "string", "main_pwd", NULL);
Expand All @@ -53,6 +54,7 @@ new_db (AppData *app_data)
g_clear_error (&err);
gtk_widget_hide (newdb_diag);
revert_db_path (app_data, old_db_path);
g_string_free (new_db_path_with_suffix, TRUE);
return RETRY_CHANGE;
}
load_new_db (app_data, &err);
Expand All @@ -61,6 +63,7 @@ new_db (AppData *app_data)
g_clear_error (&err);
gtk_widget_hide (newdb_diag);
revert_db_path (app_data, old_db_path);
g_string_free (new_db_path_with_suffix, TRUE);
return RETRY_CHANGE;
}
g_free (old_db_path);
Expand Down

0 comments on commit 338c81e

Please sign in to comment.