Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion system/fastboot/fastboot.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include <nuttx/mtd/mtd.h>
#include <nuttx/version.h>

#include <ctype.h>
#include <endian.h>
#include <errno.h>
#include <fcntl.h>
Expand Down Expand Up @@ -870,7 +871,9 @@ static int fastboot_filedump_upload(FAR struct fastboot_ctx_s *ctx)
static void fastboot_filedump(FAR struct fastboot_ctx_s *ctx,
FAR const char *arg)
{
char format[64];
struct stat sb;
int pathend;
int ret;

if (!arg)
Expand All @@ -879,8 +882,19 @@ static void fastboot_filedump(FAR struct fastboot_ctx_s *ctx,
return;
}

ret = sscanf(arg, "%s %" PRIdOFF " %zu", ctx->upload_param.u.file.path,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's problem call sscanf

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

target buffer overflow evasion?

@xiaoxiang781216 xiaoxiang781216 Jul 7, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's add %xxs?

snprintf(format, sizeof(format), "%%%zus%%n %%" PRIdOFF " %%zu",
sizeof(ctx->upload_param.u.file.path) - 1);

pathend = 0;
ret = sscanf(arg, format, ctx->upload_param.u.file.path, &pathend,
&ctx->upload_param.u.file.offset, &ctx->upload_param.size);
if (ret < 1 ||
(arg[pathend] != '\0' && !isspace((unsigned char)arg[pathend])))
{
fastboot_fail(ctx, "Invalid argument");
return;
}

if (ret != 1 && ret != 3)
{
fastboot_fail(ctx, "Failed to parse arguments");
Expand Down
Loading