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 <tiago.medicci@espressif.com>
This commit is contained in:
Tiago Medicci 2026-04-20 17:26:17 -03:00 committed by CeDeROM
parent 6cb1a04fe7
commit 9b6b7607f2

View file

@ -31,6 +31,7 @@
#include <pthread.h>
#include <stdio.h>
#include <fcntl.h>
#include <errno.h>
#include <unistd.h>
#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)