Skip to content

Commit 9b6b760

Browse files
tmediccicederom
authored andcommitted
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>
1 parent 6cb1a04 commit 9b6b760

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

system/irtest/cmd.cxx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#include <pthread.h>
3232
#include <stdio.h>
3333
#include <fcntl.h>
34+
#include <errno.h>
3435
#include <unistd.h>
3536

3637
#include "enum.hpp"
@@ -246,6 +247,17 @@ CMD1(write_data, size_t, index)
246247
data[size] = tmp;
247248
}
248249

250+
/* Avoid silently truncating long write_data commands. */
251+
252+
if (size == CONFIG_SYSTEM_IRTEST_MAX_SIRDATA)
253+
{
254+
tmp = get_next_arg < uint32_t > ();
255+
if (tmp != 0)
256+
{
257+
return -E2BIG;
258+
}
259+
}
260+
249261
/* lirc require the odd length */
250262

251263
if (size % 2 == 0)

0 commit comments

Comments
 (0)