From: Tom Rini <trini@konsulko.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 2/2] image: Protect against overflow in unknown_msg()
Date: Wed, 26 Oct 2016 17:49:01 -0400 [thread overview]
Message-ID: <20161026214901.GD18591@bill-the-cat> (raw)
In-Reply-To: <1477509552-9047-2-git-send-email-sjg@chromium.org>
On Wed, Oct 26, 2016 at 01:19:12PM -0600, Simon Glass wrote:
> Coverity complains that this can overflow. If we later increase the size
> of one of the strings in the table, it could happen.
>
> Adjust the code to protect against this.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> Reported-by: Coverity (CID: 150964)
> ---
>
> common/image.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/common/image.c b/common/image.c
> index 0e86c13..dfd1779 100644
> --- a/common/image.c
> +++ b/common/image.c
> @@ -584,13 +584,14 @@ const table_entry_t *get_table_entry(const table_entry_t *table, int id)
> }
> return NULL;
> }
> +#include <linux/string.h>
>
> static const char *unknown_msg(enum ih_category category)
> {
> static char msg[30];
>
> strcpy(msg, "Unknown ");
> - strcat(msg, table_info[category].desc);
> + strncat(msg, table_info[category].desc, sizeof(msg) - 1);
>
> return msg;
> }
We should add the include up top with the others :)
--
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20161026/2c31de01/attachment.sig>
next prev parent reply other threads:[~2016-10-26 21:49 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-26 19:19 [U-Boot] [PATCH 1/2] mkimage: Fix missing free() in show_valid_options() Simon Glass
2016-10-26 19:19 ` [U-Boot] [PATCH 2/2] image: Protect against overflow in unknown_msg() Simon Glass
2016-10-26 21:49 ` Tom Rini [this message]
2016-10-28 1:51 ` Simon Glass
2016-10-26 21:49 ` [U-Boot] [PATCH 1/2] mkimage: Fix missing free() in show_valid_options() Tom Rini
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=20161026214901.GD18591@bill-the-cat \
--to=trini@konsulko.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox