mirror of
https://github.com/apache/nuttx-apps.git
synced 2026-08-01 20:29:00 +00:00
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:
parent
6cb1a04fe7
commit
9b6b7607f2
1 changed files with 12 additions and 0 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue