From c1808fb46030f8fd5eaeb02b1751ee891279c22a Mon Sep 17 00:00:00 2001 From: Julian Oes Date: Wed, 9 Sep 2026 11:02:26 +1200 Subject: [PATCH] fix(parameters): widen the flashfs working buffer size (#28622) parameter_flashfs_alloc() assigns *buf_size + sizeof(flash_entry_header_t) to a static uint16_t, so it can only ever address 65535 bytes. Twenty-one boards give the parameter store a single 128 KiB sector, all of them H7 flight controllers that keep parameters in flash because they have no SD card. Half of that sector is unreachable by construction. Were a request to exceed the range, the wrap would be silent. There is no overflow: the caller uses the size written back through *buf_size rather than the one it asked for, so the copy stays inside the allocation. The result would be a truncated parameter blob written as if it were complete. Use size_t, as the rest of the interface already does. Reported by @lihnucs. Assisted-by: Claude:claude-opus-5[1m] Signed-off-by: Julian Oes --- src/lib/parameters/flashparams/flashfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/parameters/flashparams/flashfs.c b/src/lib/parameters/flashparams/flashfs.c index 4563489b722..7ea54fc0586 100644 --- a/src/lib/parameters/flashparams/flashfs.c +++ b/src/lib/parameters/flashparams/flashfs.c @@ -112,7 +112,7 @@ typedef begin_packed_struct struct flash_entry_header_t { * Private Data ****************************************************************************/ static uint8_t *working_buffer; -static uint16_t working_buffer_size; +static size_t working_buffer_size; static bool working_buffer_static; static sector_descriptor_t *sector_map; static int last_erased;