]> git.ipfire.org Git - thirdparty/u-boot.git/commit
cmd: fastboot: Validate user input
authorSam Protsenko <semen.protsenko@linaro.org>
Fri, 29 Jun 2018 18:59:40 +0000 (21:59 +0300)
committerMarek Vasut <marex@denx.de>
Tue, 21 Aug 2018 14:21:37 +0000 (16:21 +0200)
commitaa51579f9aecdc509c91d6a9fc9498c2495cf218
tree6c0bef39a60af70fb3f6b89ce039e80ab1a33943
parent9f8cf76be256a83643ee05de6cffaeb452ed0931
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: Sam Protsenko <semen.protsenko@linaro.org>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Lukasz Majewski <lukma@denx.de>
cmd/fastboot.c