diff options
author | Andrey Smirnov <andrew.smirnov@gmail.com> | 2018-05-22 15:26:44 -0700 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2018-05-23 10:11:53 +0200 |
commit | 6a8fee6c4eaec4f2575ce59b1b78eafd144633e2 (patch) | |
tree | 86c6580c74ad2605861ee013a5d04213df30cef8 /scripts | |
parent | 0d4a43951b1a19d87f323deabd08adc667b2f71f (diff) | |
download | barebox-6a8fee6c4eaec4f2575ce59b1b78eafd144633e2.tar.gz barebox-6a8fee6c4eaec4f2575ce59b1b78eafd144633e2.tar.xz |
scripts/mkimage: Fix strncpy usage
Original code produces the following warning when compiled with GCC8:
HOSTCC scripts/mkimage
In function ‘image_set_name’,
inlined from ‘main’ at scripts/mkimage.c:614:2:
scripts/mkimage.c:153:2: warning: ‘strncpy’ specified bound 32 equals destination size [-Wstringop-truncation]
strncpy(image_get_name(hdr), name, IH_NMLEN);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
reduce specified bound by one to make sure that NULL-terminator is
never overwritten.
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/mkimage.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/scripts/mkimage.c b/scripts/mkimage.c index c7267a2d1c..891d7b6de7 100644 --- a/scripts/mkimage.c +++ b/scripts/mkimage.c @@ -150,7 +150,7 @@ image_set_hdr_u8(comp); /* image_set_comp */ static inline void image_set_name(image_header_t *hdr, const char *name) { - strncpy(image_get_name(hdr), name, IH_NMLEN); + strncpy(image_get_name(hdr), name, IH_NMLEN - 1); } /** |