mirror of
https://github.com/apache/nuttx.git
synced 2026-08-01 20:28:58 +00:00
fs/partition: bound TXTABLE partition names
Limit the parsed TXTABLE name field to NAME_MAX and reject entries that do not provide all three required fields. This avoids writing past struct partition_s.name when a text partition table contains an overlong name. Signed-off-by: Old-Ding <35417409+Old-Ding@users.noreply.github.com>
This commit is contained in:
parent
c3494e47e3
commit
4b1a1bdca9
1 changed files with 5 additions and 2 deletions
|
|
@ -30,6 +30,7 @@
|
|||
#include <stdio.h>
|
||||
|
||||
#include <nuttx/kmalloc.h>
|
||||
#include <nuttx/macro.h>
|
||||
|
||||
#include "partition.h"
|
||||
#include "fs_heap.h"
|
||||
|
|
@ -44,6 +45,7 @@
|
|||
|
||||
#define TXTABLE_MAGIC "TXTABLE0"
|
||||
#define TXTABLE_LENGTH (state->erasesize + 1)
|
||||
#define TXTABLE_NAME_FMT "%" STRINGIFY(NAME_MAX) "s"
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
|
|
@ -157,12 +159,13 @@ int parse_txtable_partition(FAR struct partition_state_s *state,
|
|||
break;
|
||||
}
|
||||
|
||||
ret = sscanf(token, "%s %zx %zx",
|
||||
ret = sscanf(token, TXTABLE_NAME_FMT " %zx %zx",
|
||||
part[i].name,
|
||||
&part[i].nblocks,
|
||||
&part[i].firstblock);
|
||||
if (ret < 0)
|
||||
if (ret != 3)
|
||||
{
|
||||
ret = -EFTYPE;
|
||||
goto out;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue