diff --git a/MAVProxy/modules/mavproxy_param.py b/MAVProxy/modules/mavproxy_param.py index a4da69a43b..3f828b4577 100644 --- a/MAVProxy/modules/mavproxy_param.py +++ b/MAVProxy/modules/mavproxy_param.py @@ -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: @@ -474,6 +475,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": value = value ^ (1 << bit_index)