[U-Boot] [PATCH v2] usb: gadget: dynamic envstr size in cb_getvar
Nicolas le bayon
nlebayon at gmail.com
Fri Mar 10 11:03:04 UTC 2017
Hi,
here is a second patch proposal with a dynamic size allocation for evstr in
cb_getvar.
Thanks in advance for your feedback/approval.
Best Regards
Nicolas
---
---
drivers/usb/gadget/f_fastboot.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/usb/gadget/f_fastboot.c
b/drivers/usb/gadget/f_fastboot.c
index 2160b1c..8b73277 100644
--- a/drivers/usb/gadget/f_fastboot.c
+++ b/drivers/usb/gadget/f_fastboot.c
@@ -432,9 +432,11 @@ static void cb_getvar(struct usb_ep *ep, struct
usb_request *req)
else
strcpy(response, "FAILValue not set");
} else {
- char envstr[32];
+ char *envstr;
- snprintf(envstr, sizeof(envstr) - 1, "fastboot.%s", cmd);
+ envstr = malloc(sizeof("fastboot.%s", cmd) + 1);
+
+ sprintf(envstr, "fastboot.%s", cmd);
s = getenv(envstr);
if (s) {
strncat(response, s, chars_left);
--
1.9.1
More information about the U-Boot
mailing list