All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] fastboot: avoid printing invalid data
@ 2016-09-19  9:59 John Keeping
  2017-03-03  1:07 ` Steve Rae
  0 siblings, 1 reply; 3+ messages in thread
From: John Keeping @ 2016-09-19  9:59 UTC (permalink / raw)
  To: u-boot

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@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

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [U-Boot] [PATCH] fastboot: avoid printing invalid data
  2016-09-19  9:59 [U-Boot] [PATCH] fastboot: avoid printing invalid data John Keeping
@ 2017-03-03  1:07 ` Steve Rae
  2017-03-05  0:51   ` Marek Vasut
  0 siblings, 1 reply; 3+ messages in thread
From: Steve Rae @ 2017-03-03  1:07 UTC (permalink / raw)
  To: u-boot

Hi John,

On Mon, Sep 19, 2016 at 2:59 AM, John Keeping <john@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@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@raedomain.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [U-Boot] [PATCH] fastboot: avoid printing invalid data
  2017-03-03  1:07 ` Steve Rae
@ 2017-03-05  0:51   ` Marek Vasut
  0 siblings, 0 replies; 3+ messages in thread
From: Marek Vasut @ 2017-03-05  0:51 UTC (permalink / raw)
  To: u-boot

On 03/03/2017 02:07 AM, Steve Rae wrote:
> Hi John,

+CC the gadget maintainer, Lukasz ... next time, please DO CC the 
maintainer, otherwise your patch is likely to be lost.

> On Mon, Sep 19, 2016 at 2:59 AM, John Keeping <john@metanate.com
> <mailto:john@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@metanate.com
>     <mailto:john@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 <mailto:U-Boot@lists.denx.de>
>     http://lists.denx.de/mailman/listinfo/u-boot
>     <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@raedomain.com
> <mailto:steve.rae@raedomain.com>>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-03-05  0:51 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-19  9:59 [U-Boot] [PATCH] fastboot: avoid printing invalid data John Keeping
2017-03-03  1:07 ` Steve Rae
2017-03-05  0:51   ` Marek Vasut

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.