mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-03-08 06:34:22 -04:00
HAL_SITL: prevent array overruns in RCInput/RCOutput
This commit is contained in:
parent
ed099a73a3
commit
a566ebe4ec
libraries/AP_HAL_AVR_SITL
@ -18,6 +18,9 @@ bool SITLRCInput::new_input() {
|
|||||||
|
|
||||||
uint16_t SITLRCInput::read(uint8_t ch) {
|
uint16_t SITLRCInput::read(uint8_t ch) {
|
||||||
_sitlState->new_rc_input = false;
|
_sitlState->new_rc_input = false;
|
||||||
|
if (ch >= 8) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
return _override[ch]? _override[ch] : _sitlState->pwm_input[ch];
|
return _override[ch]? _override[ch] : _sitlState->pwm_input[ch];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,7 +23,9 @@ void SITLRCOutput::disable_ch(uint8_t ch)
|
|||||||
|
|
||||||
void SITLRCOutput::write(uint8_t ch, uint16_t period_us)
|
void SITLRCOutput::write(uint8_t ch, uint16_t period_us)
|
||||||
{
|
{
|
||||||
|
if (ch < 11) {
|
||||||
_sitlState->pwm_output[ch] = period_us;
|
_sitlState->pwm_output[ch] = period_us;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SITLRCOutput::write(uint8_t ch, uint16_t* period_us, uint8_t len)
|
void SITLRCOutput::write(uint8_t ch, uint16_t* period_us, uint8_t len)
|
||||||
@ -31,8 +33,12 @@ void SITLRCOutput::write(uint8_t ch, uint16_t* period_us, uint8_t len)
|
|||||||
memcpy(_sitlState->pwm_output+ch, period_us, len*sizeof(uint16_t));
|
memcpy(_sitlState->pwm_output+ch, period_us, len*sizeof(uint16_t));
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t SITLRCOutput::read(uint8_t ch) {
|
uint16_t SITLRCOutput::read(uint8_t ch)
|
||||||
|
{
|
||||||
|
if (ch < 11) {
|
||||||
return _sitlState->pwm_output[ch];
|
return _sitlState->pwm_output[ch];
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SITLRCOutput::read(uint16_t* period_us, uint8_t len)
|
void SITLRCOutput::read(uint16_t* period_us, uint8_t len)
|
||||||
|
Loading…
Reference in New Issue
Block a user