From: Stefan Roese <sr@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v2] cmd_mtdparts.c: prevent printbuffer overflows
Date: Tue, 23 Feb 2010 16:24:12 +0100 [thread overview]
Message-ID: <201002231624.12172.sr@denx.de> (raw)
In-Reply-To: <1266938310-32582-1-git-send-email-agust@denx.de>
Hi Anatolij,
On Tuesday 23 February 2010 16:18:30 Anatolij Gustschin wrote:
> The length of configured MTDPARTS_DEFAULT string
> could be greater than console printbuffer size.
> Replace printf() by puts() to avoid potential buffer
> overflows.
>
> Signed-off-by: Anatolij Gustschin <agust@denx.de>
> ---
> Changes since v1:
> - use puts() instead of printf() as suggested by Wolfgang.
>
> common/cmd_mtdparts.c | 5 +++--
> 1 files changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/common/cmd_mtdparts.c b/common/cmd_mtdparts.c
> index b375fea..0fd5ce2 100644
> --- a/common/cmd_mtdparts.c
> +++ b/common/cmd_mtdparts.c
> @@ -1254,8 +1254,9 @@ static void list_partitions(void)
> printf("\ndefaults:\n");
> printf("mtdids : %s\n",
> mtdids_default ? mtdids_default : "none");
> - printf("mtdparts: %s\n",
> - mtdparts_default ? mtdparts_default : "none");
> + puts("mtdparts: ");
> + puts(mtdparts_default ? mtdparts_default : "none");
> + puts("\n");
It might make sense to add a comment here, describing why you use these puts()
calls instead of one printf(). Otherwise somebody else might trip into this
problem again in a later time.
Cheers,
Stefan
--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-0 Fax: (+49)-8142-66989-80 Email: office at denx.de
next prev parent reply other threads:[~2010-02-23 15:24 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-02-23 15:18 [U-Boot] [PATCH v2] cmd_mtdparts.c: prevent printbuffer overflows Anatolij Gustschin
2010-02-23 15:24 ` Stefan Roese [this message]
2010-02-23 22:51 ` Anatolij Gustschin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=201002231624.12172.sr@denx.de \
--to=sr@denx.de \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.