AP_VideoTX: accept variable-length SmartAudio 2.1 settings
pre-commit / ci (push) Canceled after 0s
test Renode / cubeorangeplus-quadplane (push) Canceled after 0s
test scripts / build (astyle-cleanliness) (push) Canceled after 0s
test scripts / build (check_autotest_options) (push) Canceled after 0s
test scripts / build (logger_metadata) (push) Canceled after 0s
test scripts / build (param-file-validation) (push) Canceled after 0s
test scripts / build (param_parse) (push) Canceled after 0s
test scripts / build (python-cleanliness) (push) Canceled after 0s
test scripts / build (shellcheck) (push) Canceled after 0s
test scripts / build (validate_board_list) (push) Canceled after 0s

SmartAudio 2.1 reports a variable number of supported power levels. Validate the fixed fields, advertised level count, and CRC instead of requiring the maximum-size response struct.
This commit is contained in:
Yves
2026-09-11 10:56:05 +01:00
committed by Andy Piper
parent a5cd5f7981
commit 14c871f273
+14 -3
View File
@@ -593,16 +593,27 @@ bool AP_SmartAudio::parse_response_buffer(const uint8_t *buffer, uint8_t buffer
update_vtx_settings(settings);
break;
case SMARTAUDIO_RSP_GET_SETTINGS_V21:
if (buffer_length < sizeof(SettingsExtendedResponseFrame)) {
case SMARTAUDIO_RSP_GET_SETTINGS_V21: {
// The power level list is variable length. num_power_levels is the
// final power-level index, followed by the frame CRC.
const SettingsExtendedResponseFrame *frame =
(const SettingsExtendedResponseFrame *)buffer;
const uint8_t fixed_response_length = sizeof(frame->settings) + 2U;
if (buffer_length < fixed_response_length) {
return false;
}
const uint16_t response_length =
fixed_response_length + uint16_t(frame->num_power_levels) + 1U /* level */ + 1U /* CRC */;
if (buffer_length < response_length) {
return false;
}
_protocol_version = SMARTAUDIO_SPEC_PROTOCOL_v21;
unpack_settings(&settings, (const SettingsExtendedResponseFrame *)buffer);
unpack_settings(&settings, frame);
settings.version = SMARTAUDIO_SPEC_PROTOCOL_v21;
print_settings(&settings);
update_vtx_settings(settings);
break;
}
case SMARTAUDIO_RSP_SET_FREQUENCY: {
if (buffer_length < sizeof(U16ResponseFrame)) {