mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] usb: fastboot: increase max answer size to 256
@ 2026-01-26 13:04 Sascha Hauer
  2026-01-26 13:53 ` Marco Felsch
  2026-01-27  7:22 ` Sascha Hauer
  0 siblings, 2 replies; 4+ messages in thread
From: Sascha Hauer @ 2026-01-26 13:04 UTC (permalink / raw)
  To: Barebox List

Initial fasboot specification allowed at maximum 64 characters as
answer. This has been increased to 256 [1]. Allow for longer answer
sizes.

While at it use a define for the maximum answer length to avoid
repeating the hardcoded number. Also allow the answer to be exactly
the maximum length. Previous implementation used a 64 byte string
which included the '\0' string end and limited the usable size to
63 bytes. Now we can use the full 256 bytes.

[1] https://android.googlesource.com/platform/system/core/+/master/fastboot/

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 common/fastboot.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/common/fastboot.c b/common/fastboot.c
index b661d610a3..96d7fbd8c7 100644
--- a/common/fastboot.c
+++ b/common/fastboot.c
@@ -269,11 +269,13 @@ static char *fastboot_msg[] = {
 	[FASTBOOT_MSG_NONE] = "",
 };
 
+#define FASTBOOT_MAX_RESPONSE_SIZE 256
+
 int fastboot_tx_print(struct fastboot *fb, enum fastboot_msg_type type,
 		      const char *fmt, ...)
 {
 	struct va_format vaf;
-	char buf[64];
+	char buf[FASTBOOT_MAX_RESPONSE_SIZE + 1];
 	va_list ap;
 	int n;
 	const char *msg = fastboot_msg[type];
@@ -282,7 +284,7 @@ int fastboot_tx_print(struct fastboot *fb, enum fastboot_msg_type type,
 	vaf.fmt = fmt;
 	vaf.va = &ap;
 
-	n = snprintf(buf, 64, "%s%pV", msg, &vaf);
+	n = snprintf(buf, FASTBOOT_MAX_RESPONSE_SIZE + 1, "%s%pV", msg, &vaf);
 
 	switch (type) {
 	case FASTBOOT_MSG_OKAY:
@@ -302,8 +304,8 @@ int fastboot_tx_print(struct fastboot *fb, enum fastboot_msg_type type,
 
 	va_end(ap);
 
-	if (n > 64)
-		n = 64;
+	if (n > FASTBOOT_MAX_RESPONSE_SIZE)
+		n = FASTBOOT_MAX_RESPONSE_SIZE;
 
 	return fb->write(fb, buf, n);
 }
-- 
2.47.3




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

* Re: [PATCH] usb: fastboot: increase max answer size to 256
  2026-01-26 13:04 [PATCH] usb: fastboot: increase max answer size to 256 Sascha Hauer
@ 2026-01-26 13:53 ` Marco Felsch
  2026-01-27  7:12   ` Sascha Hauer
  2026-01-27  7:22 ` Sascha Hauer
  1 sibling, 1 reply; 4+ messages in thread
From: Marco Felsch @ 2026-01-26 13:53 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: Barebox List

Hi Sascha,

On 26-01-26, Sascha Hauer wrote:

..
> While at it use a define for the maximum answer length to avoid
> repeating the hardcoded number. Also allow the answer to be exactly
> the maximum length. Previous implementation used a 64 byte string
> which included the '\0' string end and limited the usable size to
> 63 bytes. Now we can use the full 256 bytes.

...

> +#define FASTBOOT_MAX_RESPONSE_SIZE 256
> +
>  int fastboot_tx_print(struct fastboot *fb, enum fastboot_msg_type type,
>  		      const char *fmt, ...)
>  {
>  	struct va_format vaf;
> -	char buf[64];
> +	char buf[FASTBOOT_MAX_RESPONSE_SIZE + 1];

So the new size of 256 bytes don't include the '\0' at the end?

In that case feel free to add my:

Reviewed-by: Marco Felsch <m.felsch@pengutronix.de>

Regards,
  Marco




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

* Re: [PATCH] usb: fastboot: increase max answer size to 256
  2026-01-26 13:53 ` Marco Felsch
@ 2026-01-27  7:12   ` Sascha Hauer
  0 siblings, 0 replies; 4+ messages in thread
From: Sascha Hauer @ 2026-01-27  7:12 UTC (permalink / raw)
  To: Marco Felsch; +Cc: Barebox List

On Mon, Jan 26, 2026 at 02:53:36PM +0100, Marco Felsch wrote:
> Hi Sascha,
> 
> On 26-01-26, Sascha Hauer wrote:
> 
> ..
> > While at it use a define for the maximum answer length to avoid
> > repeating the hardcoded number. Also allow the answer to be exactly
> > the maximum length. Previous implementation used a 64 byte string
> > which included the '\0' string end and limited the usable size to
> > 63 bytes. Now we can use the full 256 bytes.
> 
> ...
> 
> > +#define FASTBOOT_MAX_RESPONSE_SIZE 256
> > +
> >  int fastboot_tx_print(struct fastboot *fb, enum fastboot_msg_type type,
> >  		      const char *fmt, ...)
> >  {
> >  	struct va_format vaf;
> > -	char buf[64];
> > +	char buf[FASTBOOT_MAX_RESPONSE_SIZE + 1];
> 
> So the new size of 256 bytes don't include the '\0' at the end?

We need the '\0' for printing the string with pr_info(), but it doesn't
go over the wire.

> 
> In that case feel free to add my:
> 
> Reviewed-by: Marco Felsch <m.felsch@pengutronix.de>

Thanks
 Sascha

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



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

* Re: [PATCH] usb: fastboot: increase max answer size to 256
  2026-01-26 13:04 [PATCH] usb: fastboot: increase max answer size to 256 Sascha Hauer
  2026-01-26 13:53 ` Marco Felsch
@ 2026-01-27  7:22 ` Sascha Hauer
  1 sibling, 0 replies; 4+ messages in thread
From: Sascha Hauer @ 2026-01-27  7:22 UTC (permalink / raw)
  To: Barebox List, Sascha Hauer


On Mon, 26 Jan 2026 14:04:22 +0100, Sascha Hauer wrote:
> Initial fasboot specification allowed at maximum 64 characters as
> answer. This has been increased to 256 [1]. Allow for longer answer
> sizes.
> 
> While at it use a define for the maximum answer length to avoid
> repeating the hardcoded number. Also allow the answer to be exactly
> the maximum length. Previous implementation used a 64 byte string
> which included the '\0' string end and limited the usable size to
> 63 bytes. Now we can use the full 256 bytes.
> 
> [...]

Applied, thanks!

[1/1] usb: fastboot: increase max answer size to 256
      https://git.pengutronix.de/cgit/barebox/commit/?id=d9e213023295 (link may not be stable)

Best regards,
-- 
Sascha Hauer <s.hauer@pengutronix.de>




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

end of thread, other threads:[~2026-01-27  7:23 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-01-26 13:04 [PATCH] usb: fastboot: increase max answer size to 256 Sascha Hauer
2026-01-26 13:53 ` Marco Felsch
2026-01-27  7:12   ` Sascha Hauer
2026-01-27  7:22 ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox