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

Ensure secret exists when tyring to read as text #476

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 10 additions & 1 deletion src/keytar_posix.cc
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