From e5aa1c3cb7df36b84893e8e019eae8678e57f069 Mon Sep 17 00:00:00 2001 From: Bastien Nocera Date: Fri, 27 Apr 2018 13:47:53 +0200 Subject: [PATCH] upekts: Fix compilation warning MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit libfprint/drivers/upekts.c: In function ‘alloc_send_cmd_transfer’: libfprint/drivers/upekts.c:161:2: warning: ‘strncpy’ output truncated before terminating nul copying 4 bytes from a string of the same length [-Wstringop-truncation] strncpy(buf, "Ciao", 4); ^~~~~~~~~~~~~~~~~~~~~~~ Replace with memcpy() to only copy the 4 bytes we need. https://bugs.freedesktop.org/show_bug.cgi?id=106281 --- libfprint/drivers/upekts.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libfprint/drivers/upekts.c b/libfprint/drivers/upekts.c index b297127..4ad9552 100644 --- a/libfprint/drivers/upekts.c +++ b/libfprint/drivers/upekts.c @@ -141,6 +141,7 @@ static struct libusb_transfer *alloc_send_cmd_transfer(struct fp_dev *dev, { struct libusb_transfer *transfer = libusb_alloc_transfer(0); uint16_t crc; + const char *ciao = "Ciao"; /* 9 bytes extra for: 4 byte 'Ciao', 1 byte A, 1 byte B | lenHI, * 1 byte lenLO, 2 byte CRC */ @@ -158,7 +159,7 @@ static struct libusb_transfer *alloc_send_cmd_transfer(struct fp_dev *dev, buf = g_malloc(urblen); /* Write header */ - strncpy(buf, "Ciao", 4); + memcpy(buf, ciao, strlen(ciao)); len = GUINT16_TO_LE(len); buf[4] = seq_a; buf[5] = seq_b | ((len & 0xf00) >> 8); -- 2.17.0