[U-Boot] [PATCH] fastboot: avoid printing invalid data

Steve Rae steve.rae at raedomain.com
Fri Mar 3 01:07:23 UTC 2017


Hi John,

On Mon, Sep 19, 2016 at 2:59 AM, John Keeping <john at metanate.com> wrote:

> There is no guarantee that commands are null-terminated in the USB
> request buffer, so limit the length of data that is printed.
>
> Signed-off-by: John Keeping <john at metanate.com>
> ---
>
>  drivers/usb/gadget/f_fastboot.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/usb/gadget/f_fastboot.c
> b/drivers/usb/gadget/f_fastboot.c
> index 2160b1c..a020b7d 100644
> --- a/drivers/usb/gadget/f_fastboot.c
> +++ b/drivers/usb/gadget/f_fastboot.c
> @@ -710,7 +710,7 @@ static void rx_handler_command(struct usb_ep *ep,
> struct usb_request *req)
>         }
>
>         if (!func_cb) {
> -               error("unknown command: %s", cmdbuf);
> +               error("unknown command: %.*s", req->actual, cmdbuf);
>                 fastboot_tx_write_str("FAILunknown command");
>         } else {
>                 if (req->actual < req->length) {
> --
> 2.9.3.728.g30b24b4.dirty
>
> _______________________________________________
> U-Boot mailing list
> U-Boot at lists.denx.de
> http://lists.denx.de/mailman/listinfo/u-boot
>

This change looks OK -- but since it is the first time that "%.*s" is used
with "error()" in U-Boot; I created a test build in order to hit this error
condition and ensured that it works correctly!
Thanks!

Tested-by: Steve Rae <steve.rae at raedomain.com>


More information about the U-Boot mailing list