cederom commented on code in PR #3608:
URL: https://github.com/apache/nuttx-apps/pull/3608#discussion_r3529696633


##########
system/fastboot/fastboot.c:
##########
@@ -879,14 +881,28 @@ static void fastboot_filedump(FAR struct fastboot_ctx_s 
*ctx,
       return;
     }
 
-  ret = sscanf(arg, "%s %" PRIdOFF " %zu", ctx->upload_param.u.file.path,
+  path_len = strcspn(arg, " \t\r\n");
+  if (path_len == 0 ||
+      path_len >= sizeof(ctx->upload_param.u.file.path))
+    {
+      fastboot_fail(ctx, "Invalid argument");
+      return;
+    }
+
+  memcpy(ctx->upload_param.u.file.path, arg, path_len);
+  ctx->upload_param.u.file.path[path_len] = '\0';
+
+  params = arg + path_len;
+  params += strspn(params, " \t\r\n");
+
+  ret = sscanf(params, "%" 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)

Review Comment:
   This should go up in a separate check after file path is parsed? :-)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to