public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Tom Rini <trini@konsulko.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [U-Boot, v1] tools: mtk_image: replace strncpy(d, s, sizeof(d)) with snprintf()
Date: Mon, 17 Dec 2018 07:11:15 -0500	[thread overview]
Message-ID: <20181217121115.GK8702@bill-the-cat> (raw)
In-Reply-To: <20181211144143.2122-1-andriy.shevchenko@linux.intel.com>

On Tue, Dec 11, 2018 at 04:41:43PM +0200, Andy Shevchenko wrote:

> Starting from version 8 the GCC, i.e. C compiler, starts complaining about
> possible '\0' terminator loss or, as in this case, garbage copy.
> 
> In function ‘mtk_image_set_gen_header’,
>     inlined from ‘mtk_image_set_header’ at tools/mtk_image.c:733:3:
> tools/mtk_image.c:659:2: warning: ‘strncpy’ specified bound 12 equals destination size [-Wstringop-truncation]
>   strncpy(hdr->boot.name, bootname, sizeof(hdr->boot.name));
>   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> In function ‘mtk_brom_parse_imagename’,
>     inlined from ‘mtk_image_check_params’ at tools/mtk_image.c:388:9:
> tools/mtk_image.c:325:5: warning: ‘strncpy’ specified bound 32 equals destination size [-Wstringop-truncation]
>      strncpy(lk_name, val, sizeof(lk_name));
>      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> 
> Replace it with snprintf() to tell compiler how much room we have in the
> destination buffer for source string.
> 
> Fixes: 3b975a147c3c ("tools: MediaTek: add MTK boot header generation to mkimage")
> Cc: Ryder Lee <ryder.lee@mediatek.com>
> Cc: Weijie Gao <weijie.gao@mediatek.com>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> Reviewed-by: Weijie Gao <weijie.gao@mediatek.com>

Applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20181217/b7767982/attachment.sig>

      parent reply	other threads:[~2018-12-17 12:11 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-11 14:41 [U-Boot] [PATCH v1] tools: mtk_image: replace strncpy(d, s, sizeof(d)) with snprintf() Andy Shevchenko
2018-12-13  4:22 ` Weijie Gao
2018-12-17 12:11 ` Tom Rini [this message]

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=20181217121115.GK8702@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