AP_Param: correct maximum-length parameter sanity check

need to take into account addition of (eg.) _X suffix for VECTOR3F parameters
This commit is contained in:
Peter Barker 2024-11-13 07:23:24 +11:00 committed by Peter Barker
parent a6769e003a
commit efba110ef9

View File

@ -268,7 +268,12 @@ void AP_Param::check_group_info(const struct AP_Param::GroupInfo * group_info,
if (size == 0) {
FATAL("invalid type in %s", group_info[i].name);
}
if (prefix_length + strlen(group_info[i].name) > 16) {
uint8_t param_name_length = prefix_length + strlen(group_info[i].name);
if (type == AP_PARAM_VECTOR3F) {
// need room for _X/_Y/_Z
param_name_length += 2;
}
if (param_name_length > 16) {
FATAL("suffix is too long in %s", group_info[i].name);
}
(*total_size) += size + sizeof(struct Param_header);