Skip to content
Commit aa51579f authored by Sam Protsenko's avatar Sam Protsenko Committed by Marek Vasut
Browse files

cmd: fastboot: Validate user input



In case when user provides '-' as USB controller index, like this:

    => fastboot -

data abort occurs in strcmp() function in do_fastboot(), here:

    if (!strcmp(argv[1], "udp"))

(tested on BeagleBone Black).

That's because argv[1] is NULL when user types in the '-', and null
pointer dereference occurs in strcmp() (which is ok according to C
standard specification). So we must validate user input to prevent such
behavior.

While at it, check also the result of strtoul() function and handle
error cases properly.

Signed-off-by: default avatarSam Protsenko <semen.protsenko@linaro.org>
Reviewed-by: default avatarSimon Glass <sjg@chromium.org>
Reviewed-by: default avatarLukasz Majewski <lukma@denx.de>
parent 9f8cf76b
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment