fastboot: avoid printing invalid data
PATCH 1/1 fastboot: avoid printing invalid data
There is no guarantee that commands are null-terminated in the USB request buffer, so limit the length of data that is printed.
---
drivers/usb/gadget/f_fastboot.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/gadget/f_fastboot.c +1 -1
@@ -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) {
Signature · 1 line
2.9.3.728.g30b24b4.dirty
PATCH 1/1 fastboot: avoid printing invalid data
Hi John,
Quoted 24 lines · John Keeping
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 <[email protected]>---
drivers/usb/gadget/f_fastboot.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/usb/gadget/f_fastboot.c +1
-1@@ -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) {
Quoted 8 lines
--
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!
PATCH 1/1 fastboot: avoid printing invalid data
Quoted 1 line · Steve Rae
Hi John,
+CC the gadget maintainer, Lukasz ... next time, please DO CC the maintainer, otherwise your patch is likely to be lost.
Quoted 45 lines
On Mon, Sep 19, 2016 at 2:59 AM, John Keeping <[email protected] <mailto:[email protected]>> 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 <[email protected] <mailto:[email protected]>> --- 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:[email protected]> 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 <[email protected]<mailto:[email protected]>>