Skip to content

Commit

Permalink
modules: add sanity checking to bitmask index when setting bitmask pa…
Browse files Browse the repository at this point in the history
…rameter
  • Loading branch information
joshanne committed Dec 15, 2024
1 parent a14f834 commit e517447
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions MAVProxy/modules/mavproxy_param.py
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,7 @@ def param_bitmask_modify(self, master, args):
'''command for performing bitmask actions on a parameter'''

BITMASK_ACTIONS = ['toggle', 'set', 'clear']
NUM_BITS_MAX = 32

# Ensure we have at least an action and a parameter
if len(args) < 2:
Expand Down Expand Up @@ -473,6 +474,11 @@ def param_bitmask_modify(self, master, args):

# We don't have enough information to modify the bitmask, so bail
return

# Sanity check the bit index
if bit_index >= NUM_BITS_MAX:
print(f"Cannot perform bitmask action '{action}' on bit index {bit_index}.")
return

# We have enough information to try perform an action
if action == "toggle":
Expand Down

0 comments on commit e517447

Please sign in to comment.