From: Tom Rini Date: Mon, 17 Dec 2018 07:11:15 -0500 Subject: [U-Boot] [U-Boot, v1] tools: mtk_image: replace strncpy(d, s, sizeof(d)) with snprintf() In-Reply-To: <20181211144143.2122-1-andriy.shevchenko@linux.intel.com> References: <20181211144143.2122-1-andriy.shevchenko@linux.intel.com> Message-ID: <20181217121115.GK8702@bill-the-cat> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit To: u-boot@lists.denx.de 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 > Cc: Weijie Gao > Signed-off-by: Andy Shevchenko > Reviewed-by: Weijie Gao 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: