Skip to content

Commit

Permalink
lib: fix keychain NB crash
Browse files Browse the repository at this point in the history
Operational data should not be used on validation stage. Move the usage
to apply stage only.

Fixes FRRouting#15707.

Signed-off-by: Igor Ryzhov <[email protected]>
  • Loading branch information
idryzhov committed Apr 16, 2024
1 parent 84d1fb1 commit 5f018a3
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 5f018a3

Please sign in to comment.