mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] lib: declared buffer is too small to hold string
@ 2016-04-08  9:16 Renaud Barbier
  2016-04-12  6:05 ` Sascha Hauer
  0 siblings, 1 reply; 2+ messages in thread
From: Renaud Barbier @ 2016-04-08  9:16 UTC (permalink / raw)
  To: barebox

Displaying an unsigned 64-bit integer can be represented by up to 20
characters. The 20 bytes buffer reserved to store the formatted string
"%llu Bytes" is to small: (20 + 6) = 26. Hence, a bigger buffer is reserved
to hold this string.

Signed-off-by: Renaud Barbier <renaud.barbier@ge.com>
---
 lib/display_options.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/lib/display_options.c b/lib/display_options.c
index 2d695e4..0f65f59 100644
--- a/lib/display_options.c
+++ b/lib/display_options.c
@@ -26,7 +26,7 @@
  */
 char *size_human_readable(unsigned long long size)
 {
-	static char buf[20];
+	static char buf[30];
 	unsigned long m = 0, n;
 	unsigned long long f;
 	static const char names[] = {'E', 'P', 'T', 'G', 'M', 'K'};
-- 
1.7.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* Re: [PATCH] lib: declared buffer is too small to hold string
  2016-04-08  9:16 [PATCH] lib: declared buffer is too small to hold string Renaud Barbier
@ 2016-04-12  6:05 ` Sascha Hauer
  0 siblings, 0 replies; 2+ messages in thread
From: Sascha Hauer @ 2016-04-12  6:05 UTC (permalink / raw)
  To: Renaud Barbier; +Cc: barebox

On Fri, Apr 08, 2016 at 10:16:10AM +0100, Renaud Barbier wrote:
> Displaying an unsigned 64-bit integer can be represented by up to 20
> characters. The 20 bytes buffer reserved to store the formatted string
> "%llu Bytes" is to small: (20 + 6) = 26. Hence, a bigger buffer is reserved
> to hold this string.
> 
> Signed-off-by: Renaud Barbier <renaud.barbier@ge.com>
> ---
>  lib/display_options.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)

Applied, thanks

Sascha

> 
> diff --git a/lib/display_options.c b/lib/display_options.c
> index 2d695e4..0f65f59 100644
> --- a/lib/display_options.c
> +++ b/lib/display_options.c
> @@ -26,7 +26,7 @@
>   */
>  char *size_human_readable(unsigned long long size)
>  {
> -	static char buf[20];
> +	static char buf[30];
>  	unsigned long m = 0, n;
>  	unsigned long long f;
>  	static const char names[] = {'E', 'P', 'T', 'G', 'M', 'K'};
> -- 
> 1.7.1
> 
> 
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
> 

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

end of thread, other threads:[~2016-04-12  6:06 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-08  9:16 [PATCH] lib: declared buffer is too small to hold string Renaud Barbier
2016-04-12  6:05 ` Sascha Hauer

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