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:
parent
994061af44
commit
f433a4d67c
1 changed files with 2 additions and 1 deletions
|
@ -133,6 +133,7 @@ static struct libusb_transfer *alloc_send_cmd_transfer(struct fp_dev *dev,
|
||||||
{
|
{
|
||||||
struct libusb_transfer *transfer = libusb_alloc_transfer(0);
|
struct libusb_transfer *transfer = libusb_alloc_transfer(0);
|
||||||
uint16_t crc;
|
uint16_t crc;
|
||||||
|
const char *ciao = "Ciao";
|
||||||
|
|
||||||
/* 9 bytes extra for: 4 byte 'Ciao', 1 byte A, 1 byte B | lenHI,
|
/* 9 bytes extra for: 4 byte 'Ciao', 1 byte A, 1 byte B | lenHI,
|
||||||
* 1 byte lenLO, 2 byte CRC */
|
* 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);
|
buf = g_malloc(urblen);
|
||||||
|
|
||||||
/* Write header */
|
/* Write header */
|
||||||
strncpy(buf, "Ciao", 4);
|
memcpy(buf, ciao, strlen(ciao));
|
||||||
len = GUINT16_TO_LE(len);
|
len = GUINT16_TO_LE(len);
|
||||||
buf[4] = seq_a;
|
buf[4] = seq_a;
|
||||||
buf[5] = seq_b | ((len & 0xf00) >> 8);
|
buf[5] = seq_b | ((len & 0xf00) >> 8);
|
||||||
|
|
Loading…
Reference in a new issue