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:
Beat Küng
2019-10-16 13:13:17 +02:00
parent 173337e49c
commit 617f37afbf
2 changed files with 8 additions and 0 deletions
+4
View File
@@ -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);