From 9b6b7607f20d2ce119d14ee56da084e1ff582ac7 Mon Sep 17 00:00:00 2001 From: Tiago Medicci Date: Mon, 20 Apr 2026 17:26:17 -0300 Subject: [PATCH] system/irtest: Avoids silently truncating long write_data commands Long write_data commands can be truncated without any check due to the maximum size of CONFIG_SYSTEM_IRTEST_MAX_SIRDATA. This commit adds a check to avoid a silent fail. Signed-off-by: Tiago Medicci --- system/irtest/cmd.cxx | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/system/irtest/cmd.cxx b/system/irtest/cmd.cxx index 8dde00437..c8673c9b1 100644 --- a/system/irtest/cmd.cxx +++ b/system/irtest/cmd.cxx @@ -31,6 +31,7 @@ #include #include #include +#include #include #include "enum.hpp" @@ -246,6 +247,17 @@ CMD1(write_data, size_t, index) data[size] = tmp; } + /* Avoid silently truncating long write_data commands. */ + + if (size == CONFIG_SYSTEM_IRTEST_MAX_SIRDATA) + { + tmp = get_next_arg < uint32_t > (); + if (tmp != 0) + { + return -E2BIG; + } + } + /* lirc require the odd length */ if (size % 2 == 0)