diff options
author | Matthias P. Braendli <matthias.braendli@mpb.li> | 2018-05-14 12:11:31 +0200 |
---|---|---|
committer | Matthias P. Braendli <matthias.braendli@mpb.li> | 2018-05-14 12:11:31 +0200 |
commit | 8cbf2c99e7df9090e9182c4d7ebf69614ae056c2 (patch) | |
tree | bb9aa0ac5cbd9f269cc24b5b5048b0bd3ed65bdb /src/dabOutput/dabOutputRaw.cpp | |
parent | db2b590f1a8cdc5081706bdebea8ff6295e1e5ec (diff) | |
download | dabmux-8cbf2c99e7df9090e9182c4d7ebf69614ae056c2.tar.gz dabmux-8cbf2c99e7df9090e9182c4d7ebf69614ae056c2.tar.bz2 dabmux-8cbf2c99e7df9090e9182c4d7ebf69614ae056c2.zip |
Fix strncpy warning in output RAW
Diffstat (limited to 'src/dabOutput/dabOutputRaw.cpp')
-rw-r--r-- | src/dabOutput/dabOutputRaw.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
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; |