]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
fastboot: Fix off by 1 error
authorAndrew Goodbody <andrew.goodbody@linaro.org>
Thu, 17 Jul 2025 08:43:29 +0000 (09:43 +0100)
committerTom Rini <trini@konsulko.com>
Tue, 22 Jul 2025 17:30:14 +0000 (11:30 -0600)
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.

Signed-off-by: Andrew Goodbody <andrew.goodbody@linaro.org>
Reviewed-by: Mattijs Korpershoek <mkorpershoek@kernel.org>
drivers/fastboot/fb_command.c

index 7697139b6226bf55741d2185c909fa0822a731d9..791088bc094dff788b62cbc277cf7055f0876c00 100644 (file)
@@ -413,7 +413,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;