From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59315) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fqrPw-0007EI-Tl for qemu-devel@nongnu.org; Fri, 17 Aug 2018 22:56:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fqrPr-00026u-6Q for qemu-devel@nongnu.org; Fri, 17 Aug 2018 22:56:44 -0400 Sender: =?UTF-8?Q?Philippe_Mathieu=2DDaud=C3=A9?= From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Date: Fri, 17 Aug 2018 23:56:00 -0300 Message-Id: <20180818025600.21132-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Subject: [Qemu-devel] [PATCH] sheepdog: Replace strncpy() by g_strlcpy() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: David Hildenbrand , Howard Spoelstra , Hitoshi Mitake Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-devel@nongnu.org, qemu-trivial@nongnu.org, Liu Yuan , Jeff Cody , Kevin Wolf , Max Reitz , "open list:Sheepdog" , "open list:Sheepdog" Fedora 29 comes with GCC 8.1 which added the 'stringop-truncation' checks. Replace the strncpy() calls by g_strlcpy() to avoid the following warning: block/sheepdog.c: In function 'find_vdi_name': block/sheepdog.c:1239:5: error: 'strncpy' specified bound 256 equals destination size [-Werror=stringop-truncation] strncpy(buf + SD_MAX_VDI_LEN, tag, SD_MAX_VDI_TAG_LEN); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Reported-by: Howard Spoelstra Signed-off-by: Philippe Mathieu-Daudé --- See http://lists.nongnu.org/archive/html/qemu-devel/2018-07/msg03723.html block/sheepdog.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/block/sheepdog.c b/block/sheepdog.c index b229a664d9..5dc3d0c39e 100644 --- a/block/sheepdog.c +++ b/block/sheepdog.c @@ -1224,19 +1224,19 @@ static int find_vdi_name(BDRVSheepdogState *s, const char *filename, SheepdogVdiReq hdr; SheepdogVdiRsp *rsp = (SheepdogVdiRsp *)&hdr; unsigned int wlen, rlen = 0; - char buf[SD_MAX_VDI_LEN + SD_MAX_VDI_TAG_LEN]; + /* Ensures that the buffer is zero-filled, + * which is desirable since we'll soon be sending those bytes, and + * don't want the send_req to read uninitialized data. + */ + char buf[SD_MAX_VDI_LEN + SD_MAX_VDI_TAG_LEN] = { }; fd = connect_to_sdog(s, errp); if (fd < 0) { return fd; } - /* This pair of strncpy calls ensures that the buffer is zero-filled, - * which is desirable since we'll soon be sending those bytes, and - * don't want the send_req to read uninitialized data. - */ - strncpy(buf, filename, SD_MAX_VDI_LEN); - strncpy(buf + SD_MAX_VDI_LEN, tag, SD_MAX_VDI_TAG_LEN); + g_strlcpy(buf, filename, SD_MAX_VDI_LEN); + g_strlcpy(buf + SD_MAX_VDI_LEN, tag, SD_MAX_VDI_TAG_LEN); memset(&hdr, 0, sizeof(hdr)); if (lock) { -- 2.18.0