From 8cbf2c99e7df9090e9182c4d7ebf69614ae056c2 Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Mon, 14 May 2018 12:11:31 +0200 Subject: Fix strncpy warning in output RAW --- src/dabOutput/dabOutputRaw.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src/dabOutput') diff --git a/src/dabOutput/dabOutputRaw.cpp b/src/dabOutput/dabOutputRaw.cpp index 42248c5..edd1dd7 100644 --- a/src/dabOutput/dabOutputRaw.cpp +++ b/src/dabOutput/dabOutputRaw.cpp @@ -206,7 +206,9 @@ int DabOutputRaw::Open(const char* name) struct ifreq ifr; struct sockaddr_ll saddr; memset(&ifr, 0, sizeof(struct ifreq)); - (void)strncpy(ifr.ifr_name, filename, sizeof(ifr.ifr_name)); + if (sizeof(ifr.ifr_name) > 0) { + strncpy(ifr.ifr_name, filename, sizeof(ifr.ifr_name) - 1); + } // Get current Farsync configuration struct fstioc_info info; @@ -363,7 +365,10 @@ int DabOutputRaw::Open(const char* name) // ioctl to read the interface number memset(&ifr, 0, sizeof(struct ifreq)); - strncpy(ifr.ifr_name, filename, sizeof(ifr.ifr_name)); + if (sizeof(ifr.ifr_name) > 0) { + strncpy(ifr.ifr_name, filename, sizeof(ifr.ifr_name) - 1); + } + if (ioctl(socket_, SIOCGIFINDEX, (char *) &ifr) == -1) { perror(filename); return -1; -- cgit v1.2.3