[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH for-3.1? 1/3] sheepdog: fix stringop-truncation warn
From: |
Marc-André Lureau |
Subject: |
[Qemu-devel] [PATCH for-3.1? 1/3] sheepdog: fix stringop-truncation warning |
Date: |
Tue, 20 Nov 2018 19:27:51 +0400 |
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=stringop-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é Lureau <address@hidden>
---
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, const 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);
memset(&hdr, 0, sizeof(hdr));
--
2.19.1.708.g4ede3d42df
[Qemu-devel] [PATCH for-3.1? 3/3] acpi: fix stringop-truncation warnings, Marc-André Lureau, 2018/11/20