* [U-Boot] [PATCH v5 1/1] usb: gadget: avoid variable name clipping in cb_getvar
@ 2017-03-17 9:57 Nicolas le bayon
2017-03-17 12:26 ` Marek Vasut
0 siblings, 1 reply; 4+ messages in thread
From: Nicolas le bayon @ 2017-03-17 9:57 UTC (permalink / raw)
To: u-boot
From: Nicolas Le Bayon <nlebayon@gmail.com>
Instead of using a fixed-size array to store variable name, preferring a
dynamic allocation treats correctly all variable name lengths.
Variable names are growing through releases and features. By this way, name
clipping is prevented.
Signed-off-by: Nicolas Le Bayon <nlebayon@gmail.com>
---
drivers/usb/gadget/f_fastboot.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/drivers/usb/gadget/f_fastboot.c b/drivers/usb/gadget/f_
fastboot.c
index 2160b1c..7cd6d24 100644
--- a/drivers/usb/gadget/f_fastboot.c
+++ b/drivers/usb/gadget/f_fastboot.c
@@ -432,9 +432,15 @@ 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(strlen("fastboot.") + strlen(cmd) + 1);
+ if (!envstr) {
+ fastboot_tx_write_str("FAILmalloc error");
+ return;
+ }
+
+ sprintf(envstr, "fastboot.%s", cmd);
s = getenv(envstr);
if (s) {
strncat(response, s, chars_left);
@@ -442,6 +448,8 @@ static void cb_getvar(struct usb_ep *ep, struct
usb_request *req)
printf("WARNING: unknown variable: %s\n", cmd);
strcpy(response, "FAILVariable not implemented");
}
+
+ free(envstr);
}
fastboot_tx_write_str(response);
}
--
1.9.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [U-Boot] [PATCH v5 1/1] usb: gadget: avoid variable name clipping in cb_getvar
2017-03-17 9:57 [U-Boot] [PATCH v5 1/1] usb: gadget: avoid variable name clipping in cb_getvar Nicolas le bayon
@ 2017-03-17 12:26 ` Marek Vasut
2017-03-21 8:53 ` Nicolas le bayon
0 siblings, 1 reply; 4+ messages in thread
From: Marek Vasut @ 2017-03-17 12:26 UTC (permalink / raw)
To: u-boot
On 03/17/2017 10:57 AM, Nicolas le bayon wrote:
> From: Nicolas Le Bayon <nlebayon@gmail.com>
>
> Instead of using a fixed-size array to store variable name, preferring a
> dynamic allocation treats correctly all variable name lengths.
> Variable names are growing through releases and features. By this way, name
> clipping is prevented.
>
> Signed-off-by: Nicolas Le Bayon <nlebayon@gmail.com>
FYI, you should keep changelog on patchsets > V1 .
Reviewed-by: Marek Vasut <marex@denx.de>
You still need Ack from Lukasz ...
> ---
> drivers/usb/gadget/f_fastboot.c | 12 ++++++++++--
> 1 file changed, 10 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/usb/gadget/f_fastboot.c b/drivers/usb/gadget/f_
> fastboot.c
> index 2160b1c..7cd6d24 100644
> --- a/drivers/usb/gadget/f_fastboot.c
> +++ b/drivers/usb/gadget/f_fastboot.c
> @@ -432,9 +432,15 @@ 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(strlen("fastboot.") + strlen(cmd) + 1);
> + if (!envstr) {
> + fastboot_tx_write_str("FAILmalloc error");
> + return;
> + }
> +
> + sprintf(envstr, "fastboot.%s", cmd);
> s = getenv(envstr);
> if (s) {
> strncat(response, s, chars_left);
> @@ -442,6 +448,8 @@ static void cb_getvar(struct usb_ep *ep, struct
> usb_request *req)
> printf("WARNING: unknown variable: %s\n", cmd);
> strcpy(response, "FAILVariable not implemented");
> }
> +
> + free(envstr);
> }
> fastboot_tx_write_str(response);
> }
> --
> 1.9.1
>
--
Best regards,
Marek Vasut
^ permalink raw reply [flat|nested] 4+ messages in thread
* [U-Boot] [PATCH v5 1/1] usb: gadget: avoid variable name clipping in cb_getvar
2017-03-17 12:26 ` Marek Vasut
@ 2017-03-21 8:53 ` Nicolas le bayon
2017-03-28 9:10 ` Nicolas le bayon
0 siblings, 1 reply; 4+ messages in thread
From: Nicolas le bayon @ 2017-03-21 8:53 UTC (permalink / raw)
To: u-boot
Hi Lukasz,
Would it be possible to have a look at this patch and review it please?
Thanks in advance for your time
Best Regards
Nicolas
2017-03-17 13:26 GMT+01:00 Marek Vasut <marex@denx.de>:
> On 03/17/2017 10:57 AM, Nicolas le bayon wrote:
> > From: Nicolas Le Bayon <nlebayon@gmail.com>
> >
> > Instead of using a fixed-size array to store variable name, preferring a
> > dynamic allocation treats correctly all variable name lengths.
> > Variable names are growing through releases and features. By this way,
> name
> > clipping is prevented.
> >
> > Signed-off-by: Nicolas Le Bayon <nlebayon@gmail.com>
>
> FYI, you should keep changelog on patchsets > V1 .
>
> Reviewed-by: Marek Vasut <marex@denx.de>
>
> You still need Ack from Lukasz ...
>
> > ---
> > drivers/usb/gadget/f_fastboot.c | 12 ++++++++++--
> > 1 file changed, 10 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/usb/gadget/f_fastboot.c b/drivers/usb/gadget/f_
> > fastboot.c
> > index 2160b1c..7cd6d24 100644
> > --- a/drivers/usb/gadget/f_fastboot.c
> > +++ b/drivers/usb/gadget/f_fastboot.c
> > @@ -432,9 +432,15 @@ 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(strlen("fastboot.") + strlen(cmd) + 1);
> > + if (!envstr) {
> > + fastboot_tx_write_str("FAILmalloc error");
> > + return;
> > + }
> > +
> > + sprintf(envstr, "fastboot.%s", cmd);
> > s = getenv(envstr);
> > if (s) {
> > strncat(response, s, chars_left);
> > @@ -442,6 +448,8 @@ static void cb_getvar(struct usb_ep *ep, struct
> > usb_request *req)
> > printf("WARNING: unknown variable: %s\n", cmd);
> > strcpy(response, "FAILVariable not implemented");
> > }
> > +
> > + free(envstr);
> > }
> > fastboot_tx_write_str(response);
> > }
> > --
> > 1.9.1
> >
>
>
> --
> Best regards,
> Marek Vasut
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* [U-Boot] [PATCH v5 1/1] usb: gadget: avoid variable name clipping in cb_getvar
2017-03-21 8:53 ` Nicolas le bayon
@ 2017-03-28 9:10 ` Nicolas le bayon
0 siblings, 0 replies; 4+ messages in thread
From: Nicolas le bayon @ 2017-03-28 9:10 UTC (permalink / raw)
To: u-boot
Hi Lukasz,
A kind reminder to look at this patch (already reviewed by Marek).
Thanks in advance for your time
Best Regards
Nicolas
2017-03-21 9:53 GMT+01:00 Nicolas le bayon <nlebayon@gmail.com>:
> Hi Lukasz,
>
> Would it be possible to have a look at this patch and review it please?
>
> Thanks in advance for your time
>
> Best Regards
> Nicolas
>
>
> 2017-03-17 13:26 GMT+01:00 Marek Vasut <marex@denx.de>:
>
>> On 03/17/2017 10:57 AM, Nicolas le bayon wrote:
>> > From: Nicolas Le Bayon <nlebayon@gmail.com>
>> >
>> > Instead of using a fixed-size array to store variable name, preferring a
>> > dynamic allocation treats correctly all variable name lengths.
>> > Variable names are growing through releases and features. By this way,
>> name
>> > clipping is prevented.
>> >
>> > Signed-off-by: Nicolas Le Bayon <nlebayon@gmail.com>
>>
>> FYI, you should keep changelog on patchsets > V1 .
>>
>> Reviewed-by: Marek Vasut <marex@denx.de>
>>
>> You still need Ack from Lukasz ...
>>
>> > ---
>> > drivers/usb/gadget/f_fastboot.c | 12 ++++++++++--
>> > 1 file changed, 10 insertions(+), 2 deletions(-)
>> >
>> > diff --git a/drivers/usb/gadget/f_fastboot.c b/drivers/usb/gadget/f_
>> > fastboot.c
>> > index 2160b1c..7cd6d24 100644
>> > --- a/drivers/usb/gadget/f_fastboot.c
>> > +++ b/drivers/usb/gadget/f_fastboot.c
>> > @@ -432,9 +432,15 @@ 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(strlen("fastboot.") + strlen(cmd) + 1);
>> > + if (!envstr) {
>> > + fastboot_tx_write_str("FAILmalloc error");
>> > + return;
>> > + }
>> > +
>> > + sprintf(envstr, "fastboot.%s", cmd);
>> > s = getenv(envstr);
>> > if (s) {
>> > strncat(response, s, chars_left);
>> > @@ -442,6 +448,8 @@ static void cb_getvar(struct usb_ep *ep, struct
>> > usb_request *req)
>> > printf("WARNING: unknown variable: %s\n", cmd);
>> > strcpy(response, "FAILVariable not
>> implemented");
>> > }
>> > +
>> > + free(envstr);
>> > }
>> > fastboot_tx_write_str(response);
>> > }
>> > --
>> > 1.9.1
>> >
>>
>>
>> --
>> Best regards,
>> Marek Vasut
>>
>
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-03-28 9:10 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-17 9:57 [U-Boot] [PATCH v5 1/1] usb: gadget: avoid variable name clipping in cb_getvar Nicolas le bayon
2017-03-17 12:26 ` Marek Vasut
2017-03-21 8:53 ` Nicolas le bayon
2017-03-28 9:10 ` Nicolas le bayon
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.