Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lib: fix keychain NB crash #15771

Merged
merged 1 commit into from
Apr 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions lib/keychain_nb.c
Original file line number Diff line number Diff line change
Expand Up @@ -545,10 +545,6 @@ static int key_chains_key_chain_key_crypto_algorithm_modify(struct nb_cb_modify_
if (args->event != NB_EV_VALIDATE && args->event != NB_EV_APPLY)
return NB_OK;

name = yang_dnode_get_string(args->dnode, "../../name");
keychain = keychain_lookup(name);
index = (uint32_t)yang_dnode_get_uint64(args->dnode, "../key-id");
key = key_lookup(keychain, index);
name = yang_dnode_get_string(args->dnode, NULL);
if (!strncmp(name, prefix, prefix_len))
name += prefix_len;
Expand All @@ -570,6 +566,10 @@ static int key_chains_key_chain_key_crypto_algorithm_modify(struct nb_cb_modify_
}

assert(args->event == NB_EV_APPLY);
name = yang_dnode_get_string(args->dnode, "../../name");
keychain = keychain_lookup(name);
index = (uint32_t)yang_dnode_get_uint64(args->dnode, "../key-id");
key = key_lookup(keychain, index);
key->hash_algo = hash_algo;

keychain_touch(keychain);
Expand Down
Loading