Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Commit

Permalink
Ensure secret exists when tyring to read as text
Browse files Browse the repository at this point in the history
  • Loading branch information
jsimonet committed Nov 7, 2022
1 parent deae59a commit 5dc6af0
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/keytar_posix.cc
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,16 @@ KEYTAR_OP_RESULT FindCredentials(const std::string& service,
reinterpret_cast<char*>(g_hash_table_lookup(itemAttrs, "account")));

SecretValue* secret = secret_item_get_secret(item);
char* password = strdup(secret_value_get_text(secret));
if (secret == NULL) {
// keystore is not open, secret is NULL which may lead to a crash in secret_value_get_text
continue;
}

const gchar* secret_text = secret_value_get_text(secret);
char* password = NULL;
if (secret_text != NULL) {
password = strdup(secret_text);
}

if (account == NULL || password == NULL) {
if (account)
Expand Down

0 comments on commit 5dc6af0

Please sign in to comment.