From d143e5d8b558b4b126feb197af03d4451ef5c67d Mon Sep 17 00:00:00 2001 From: Khem Raj Date: Mon, 7 May 2018 19:53:33 -0700 Subject: [PATCH 1/2] Replace strncpy with memcpy gcc8 detects that strncpy is overwiritng the null terminating character the source strings are already initialized to 0 so memcpy would do the same job Fixes rn2903.c:153:5: error: 'strncpy' output may be truncated copying 16 bytes from a string of length 511 [-Werror=stringop-truncation] strncpy(dev->hardware_eui, dev->resp_data, RN2903_MAX_HEX_EUI64); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Signed-off-by: Khem Raj %% original patch: 0001-Replace-strncpy-with-memcpy.patch --- src/ecezo/ecezo.c | 2 +- src/rn2903/rn2903.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ecezo/ecezo.c b/src/ecezo/ecezo.c index 6a195fc1..56c6dab3 100644 --- a/src/ecezo/ecezo.c +++ b/src/ecezo/ecezo.c @@ -488,7 +488,7 @@ int ecezo_send_command(const ecezo_context dev, char *cmd, char *buffer, // our write buffer char writeBuffer[ECEZO_MAX_BUFFER_LEN]; - strncpy(writeBuffer, cmd, ECEZO_MAX_BUFFER_LEN); + memcpy(writeBuffer, cmd, ECEZO_MAX_BUFFER_LEN-1); writeBuffer[ECEZO_MAX_BUFFER_LEN - 1] = 0; int writelen = strlen(writeBuffer); diff --git a/src/rn2903/rn2903.c b/src/rn2903/rn2903.c index f30a33ae..01a011da 100644 --- a/src/rn2903/rn2903.c +++ b/src/rn2903/rn2903.c @@ -150,7 +150,7 @@ static rn2903_context _rn2903_postinit(rn2903_context dev, rn2903_close(dev); return NULL; } - strncpy(dev->hardware_eui, dev->resp_data, RN2903_MAX_HEX_EUI64); + memcpy(dev->hardware_eui, dev->resp_data, RN2903_MAX_HEX_EUI64); return dev; } From 48a580bd402cf6a3ee9e42013653219bfeb3caf6 Mon Sep 17 00:00:00 2001 From: Khem Raj Date: Thu, 21 Jun 2018 18:39:16 -0700 Subject: [PATCH 2/2] include sys/types.h for uint definition uint is defined in sys/types.h, therefore this header needs to be included, it gets exposed with musl where this header is not getting included indirectly as it is happening when building on glibc Fixes build errors on musl e.g. upm/src/kx122/kx122.hpp:456:31: error: 'uint' has not been declared | void setBufferThreshold(uint samples); | ^~~~ Signed-off-by: Khem Raj --- src/kx122/kx122.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/kx122/kx122.h b/src/kx122/kx122.h index 1622ed50..56e5215e 100644 --- a/src/kx122/kx122.h +++ b/src/kx122/kx122.h @@ -31,6 +31,7 @@ extern "C"{ #include #include #include +#include #include #include