Skip to content

Commit

Permalink
Fix: corosync: should validate linknumber (ClusterLabs#1546)
Browse files Browse the repository at this point in the history
  • Loading branch information
nicholasyang2022 committed Sep 9, 2024
1 parent af15166 commit 29d8fea
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions crmsh/corosync.py
Original file line number Diff line number Diff line change
Expand Up @@ -682,7 +682,7 @@ def update_link(self, linknumber: int, options: dict[str, str|None]) -> dict:
Returns: updated configuration dom. The internal state of LinkManager is also updated.
"""
links = self.links()
if links[linknumber] is None:
if linknumber >= KNET_LINK_NUM_LIMIT or links[linknumber] is None:
raise ValueError(f'Link {linknumber} does not exist.')
if 'nodes' in options:
raise ValueError('Unknown option "nodes".')
Expand Down Expand Up @@ -735,7 +735,7 @@ def update_node_addr(self, linknumber: int, node_addresses: typing.Mapping[int,
Returns: updated configuration dom. The internal state of LinkManager is also updated.
"""
links = self.links()
if links[linknumber] is None:
if linknumber >= KNET_LINK_NUM_LIMIT or links[linknumber] is None:
raise ValueError(f'Link {linknumber} does not exist.')
return self.__upsert_node_addr_impl(self._config, links, linknumber, node_addresses)

Expand Down Expand Up @@ -804,7 +804,7 @@ def remove_link(self, linknumber: int) -> dict:
Returns: updated configuration dom. The internal state of LinkManager is also updated.
"""
links = self.links()
if links[linknumber] is None:
if linknumber >= KNET_LINK_NUM_LIMIT or links[linknumber] is None:
raise ValueError(f'Link {linknumber} does not exist.')
if sum(1 if link is not None else 0 for link in links) <= 1:
raise ValueError(f'Cannot remove the last link.')
Expand Down

0 comments on commit 29d8fea

Please sign in to comment.