fastboot: Fix off by 1 error
PATCH 1/1 fastboot: Fix off by 1 error
strlen only reports length of string not including terminating 0 byte but this has to be included in length of receiving buffer on copy so adjust length check to be correct.
This issue found by Smatch.
--- drivers/fastboot/fb_command.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/fastboot/fb_command.c +1 -1
@@ -405,7 +405,7 @@ static void __maybe_unused run_acmd(char *cmd_parameter, char *response)return ; } -if (strlen (cmd_parameter) >sizeof (g_a_cmd_buff)) { +if (strlen (cmd_parameter) >=sizeof (g_a_cmd_buff)) {pr_err ("too long command\n" );fastboot_fail ("too long command" , response);return ;
---
base-commit: 3b4604a40b9fd61b87e9d059fc56f04d36f1a380
change-id: 20250717-fb_command-275ca03b1f03
Best regards,
Signature · 1 line
Andrew Goodbody <[email protected]>
Hi Andrew,
Thank you for the patch.
Quoted 5 lines · Andrew Goodbody
strlen only reports length of string not including terminating 0 byte but this has to be included in length of receiving buffer on copy so adjust length check to be correct.
This issue found by Smatch.
This issue was*
Quoted 2 lines
Signed-off-by Andrew Goodbody <[email protected]>
Good catch!
Quoted 25 lines
--- drivers/fastboot/fb_command.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/fastboot/fb_command.c +1
-2@@ -405,7 +405,7 @@ static void __maybe_unused run_acmd(char *cmd_parameter, char *response)return ; } -if (strlen (cmd_parameter) >sizeof (g_a_cmd_buff)) { +if (strlen (cmd_parameter) >=sizeof (g_a_cmd_buff)) {pr_err ("too long command\n" );fastboot_fail ("too long command" , response);return ; ---base-commit:
3b4604a40b9fd61b87e9d059fc56f04d36f1a380
change-id: 20250717-fb_command-275ca03b1f03Best regards,
Signature · 1 line
Andrew Goodbody <[email protected]>
Quoted 8 lines · Andrew Goodbody
strlen only reports length of string not including terminating 0 byte but this has to be included in length of receiving buffer on copy so adjust length check to be correct.
This issue found by Smatch.
[...]
Applied to u-boot/master, thanks!
[1/1] fastboot: Fix off by 1 error
commit: 23d2c182d4be9f993a4e4d8f4fc6293e4d5a9ff8
Signature · 1 line
Tom