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
23 changes: 20 additions & 3 deletions system/fastboot/fastboot.c
Original file line number Diff line number Diff line change
Expand Up @@ -871,6 +871,7 @@ static void fastboot_filedump(FAR struct fastboot_ctx_s *ctx,
FAR const char *arg)
{
struct stat sb;
size_t len;
int ret;

if (!arg)
Expand All @@ -879,14 +880,30 @@ static void fastboot_filedump(FAR struct fastboot_ctx_s *ctx,
return;
}

ret = sscanf(arg, "%s %" PRIdOFF " %zu", ctx->upload_param.u.file.path,
Comment thread
xiaoxiang781216 marked this conversation as resolved.
arg += strspn(arg, " \t\r\n");
len = strcspn(arg, " \t\r\n");
if (len == 0)
{
fastboot_fail(ctx, "Failed to parse arguments");
return;
}

if (len >= sizeof(ctx->upload_param.u.file.path))
{
len = sizeof(ctx->upload_param.u.file.path) - 1;
}

memcpy(ctx->upload_param.u.file.path, arg, len);
ctx->upload_param.u.file.path[len] = '\0';

ret = sscanf(arg + len, "%" PRIdOFF " %zu",
&ctx->upload_param.u.file.offset, &ctx->upload_param.size);
if (ret != 1 && ret != 3)
if (ret != EOF && ret != 0 && ret != 2)
{
fastboot_fail(ctx, "Failed to parse arguments");
return;
}
else if (ret == 1)
else if (ret != 2)
{
ret = stat(ctx->upload_param.u.file.path, &sb);
if (ret < 0)
Expand Down
Loading