Skip to content

Commit 7c9e5cb

Browse files
authored
CBST2-08: Validate participant ID for Dirk signer (#296)
1 parent 6c9df79 commit 7c9e5cb

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

crates/signer/src/manager/dirk.rs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -659,9 +659,22 @@ fn load_distributed_accounts(
659659
continue;
660660
};
661661

662+
if participant_id == 0 {
663+
warn!(
664+
"Skiping invalid participant ID (0) for account {} in host {host_name}",
665+
account.name
666+
);
667+
continue
668+
}
669+
662670
match consensus_accounts.get_mut(&public_key) {
663671
Some(Account::Distributed(DistributedAccount { participants, .. })) => {
664-
participants.insert(participant_id as u32, channel.clone());
672+
if participants.insert(participant_id as u32, channel.clone()).is_some() {
673+
warn!(
674+
"Duplicated participant ID ({participant_id}) for account {} in host {host_name}. Keeping this host",
675+
account.name
676+
);
677+
}
665678
}
666679
None => {
667680
let Ok((wallet, name)) = decompose_name(&account.name) else {

0 commit comments

Comments
 (0)