From efba110ef9eed5587cc8280323f0794e655b1f6f Mon Sep 17 00:00:00 2001 From: Peter Barker Date: Wed, 13 Nov 2024 07:23:24 +1100 Subject: [PATCH] AP_Param: correct maximum-length parameter sanity check need to take into account addition of (eg.) _X suffix for VECTOR3F parameters --- libraries/AP_Param/AP_Param.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/libraries/AP_Param/AP_Param.cpp b/libraries/AP_Param/AP_Param.cpp index 2249d98b0d..9962780398 100644 --- a/libraries/AP_Param/AP_Param.cpp +++ b/libraries/AP_Param/AP_Param.cpp @@ -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);