From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34340) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gP7x1-0003wk-7R for qemu-devel@nongnu.org; Tue, 20 Nov 2018 10:28:31 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gP7wz-00059x-1o for qemu-devel@nongnu.org; Tue, 20 Nov 2018 10:28:31 -0500 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Date: Tue, 20 Nov 2018 19:27:51 +0400 Message-Id: <20181120152753.10463-2-marcandre.lureau@redhat.com> In-Reply-To: <20181120152753.10463-1-marcandre.lureau@redhat.com> References: <20181120152753.10463-1-marcandre.lureau@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PATCH for-3.1? 1/3] sheepdog: fix stringop-truncation warning List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, Kevin Wolf , Juan Quintela , Max Reitz , Jeff Cody , Liu Yuan , Igor Mammedov , "Michael S. Tsirkin" , "Dr. David Alan Gilbert" , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= It seems adding an assert is enough to silence GCC. (sd_parse_snapid_or_tag() g_strlcpy() ensures that we don't get in that situation) ~/src/qemu/block/sheepdog.c: In function 'find_vdi_name': ~/src/qemu/block/sheepdog.c:1239:5: error: 'strncpy' specified bound 256 = equals destination size [-Werror=3Dstringop-truncation] strncpy(buf + SD_MAX_VDI_LEN, tag, SD_MAX_VDI_TAG_LEN); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ cc1: all warnings being treated as errors Signed-off-by: Marc-Andr=C3=A9 Lureau --- block/sheepdog.c | 1 + 1 file changed, 1 insertion(+) diff --git a/block/sheepdog.c b/block/sheepdog.c index 0125df9d49..f8877b611d 100644 --- a/block/sheepdog.c +++ b/block/sheepdog.c @@ -1236,6 +1236,7 @@ static int find_vdi_name(BDRVSheepdogState *s, cons= t char *filename, * don't want the send_req to read uninitialized data. */ strncpy(buf, filename, SD_MAX_VDI_LEN); + assert(strlen(tag) < SD_MAX_VDI_TAG_LEN); strncpy(buf + SD_MAX_VDI_LEN, tag, SD_MAX_VDI_TAG_LEN); =20 memset(&hdr, 0, sizeof(hdr)); --=20 2.19.1.708.g4ede3d42df