Skip to content

Commit

Permalink
Merge pull request #15771 from idryzhov/fix-keychain-crash
Browse files Browse the repository at this point in the history
lib: fix keychain NB crash
  • Loading branch information
donaldsharp authored Apr 17, 2024
2 parents e9a3326 + 5f018a3 commit e145b0c
Showing 1 changed file with 4 additions and 4 deletions.
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

0 comments on commit e145b0c

Please sign in to comment.