mirror of
https://gitlab.freedesktop.org/libfprint/libfprint.git
synced 2025-11-15 07:38:12 +00:00
upekts: Fix compilation warning
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
This commit is contained in:
@@ -133,6 +133,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 */
|
||||
@@ -150,7 +151,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);
|
||||
|
||||
Reference in New Issue
Block a user