mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-04-29 10:04:06 +08:00
mixer_{multicopter,helicopter}: add buffer size check
Fixes a potential buffer overflow if an MC/helicopter mixer is used that exceeds the number of physical pins. This is not a useful/flyable configuration, but the system still should not crash.
This commit is contained in:
parent
173337e49c
commit
617f37afbf
@ -200,6 +200,10 @@ HelicopterMixer::from_text(Mixer::ControlCallback control_cb, uintptr_t cb_handl
|
||||
unsigned
|
||||
HelicopterMixer::mix(float *outputs, unsigned space)
|
||||
{
|
||||
if (space < _mixer_info.control_count + 1u) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Find index to use for curves */
|
||||
float thrust_cmd = get_control(0, 3);
|
||||
int idx = (thrust_cmd / 0.25f);
|
||||
|
||||
@ -354,6 +354,10 @@ void MultirotorMixer::mix_yaw(float yaw, float *outputs)
|
||||
unsigned
|
||||
MultirotorMixer::mix(float *outputs, unsigned space)
|
||||
{
|
||||
if (space < _rotor_count) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
float roll = math::constrain(get_control(0, 0) * _roll_scale, -1.0f, 1.0f);
|
||||
float pitch = math::constrain(get_control(0, 1) * _pitch_scale, -1.0f, 1.0f);
|
||||
float yaw = math::constrain(get_control(0, 2) * _yaw_scale, -1.0f, 1.0f);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user