From 57d15fe717a0cc4f33e71795e0b23a5e6dff3a55 Mon Sep 17 00:00:00 2001 From: Peter Barker Date: Mon, 2 May 2022 14:48:35 +1000 Subject: [PATCH] AP_Filesystem: correct run-length encoding in param download If a parameter's name was a prefix of the previous name we would suffer an integer-wrap problem and incorrectly encode the parameter name --- libraries/AP_Filesystem/AP_Filesystem_Param.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/libraries/AP_Filesystem/AP_Filesystem_Param.cpp b/libraries/AP_Filesystem/AP_Filesystem_Param.cpp index 5d3203227c..a10e4a6f9a 100644 --- a/libraries/AP_Filesystem/AP_Filesystem_Param.cpp +++ b/libraries/AP_Filesystem/AP_Filesystem_Param.cpp @@ -181,7 +181,12 @@ uint8_t AP_Filesystem_Param::pack_param(const struct rfile &r, struct cursor &c, pname++; last_name++; } - const uint8_t name_len = strlen(pname); + uint8_t name_len = strlen(pname); + if (name_len == 0) { + name_len = 1; + common_len--; + pname--; + } const uint8_t type_len = AP_Param::type_size(ptype); uint8_t packed_len = type_len + name_len + 2; const uint8_t flags = 0;