1
0
Fork 0

fastboot: Correct fastboot_fail and fastboot_okay strings

If the string is copied without NULL termination using strncpy(),
then strncat() on the next line, may concatenate the string after
some stale (or random) data, if the response string was not
zero-initialized.

Signed-off-by: Dileep Katta <dileep.katta@linaro.org>
Reviewed-by: Steve Rae <srae@broadcom.com>
Reviewed-by: Lukasz Majewski <l.majewski@samsung.com>
utp
Dileep Katta 2015-02-13 14:33:42 +08:00 committed by Marek Vasut
parent 9e4b510d40
commit e874207134
1 changed files with 2 additions and 2 deletions

View File

@ -23,13 +23,13 @@ static char *response_str;
void fastboot_fail(const char *s)
{
strncpy(response_str, "FAIL", 4);
strncpy(response_str, "FAIL\0", 5);
strncat(response_str, s, RESPONSE_LEN - 4 - 1);
}
void fastboot_okay(const char *s)
{
strncpy(response_str, "OKAY", 4);
strncpy(response_str, "OKAY\0", 5);
strncat(response_str, s, RESPONSE_LEN - 4 - 1);
}