Print

Print


Hi,

I'm the package maintainer for Arch Linux and got this warning after the GCC 8.1 upgrade:
```cpp
/home/gizdov/Packages/builds/xrootd/src/xrootd-4.8.3/src/XrdApps/XrdCpFile.cc: In constructor ‘XrdCpFile::XrdCpFile(const char*, int&)’:
/home/gizdov/Packages/builds/xrootd/src/xrootd-4.8.3/src/XrdApps/XrdCpFile.cc:91:20: error: ‘char* strncpy(char*, const char*, size_t)’ output may be truncated copying 8 bytes from a string of length 8 [-Werror=stringop-truncation]
             strncpy(ProtName, pTab[i].pHdr, sizeof(ProtName));
             ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1plus: all warnings being treated as errors
```
which prevents the build. I could overwrite the `-Werror` flag, but I'd rather keep it as the dev intended. For the moment, I have patched the issue with the following:
```diff
diff -aur xrootd-4.8.3-old/src/XrdApps/XrdCpFile.cc xrootd-4.8.3-new/src/XrdApps/XrdCpFile.cc
--- xrootd-4.8.3-old/src/XrdApps/XrdCpFile.cc	2018-05-13 19:01:03.602433537 +0200
+++ xrootd-4.8.3-new/src/XrdApps/XrdCpFile.cc	2018-05-13 19:01:48.269454421 +0200
@@ -88,7 +88,7 @@
    for (i = 0; i < pTnum; i++)
        {if (!strncmp(FSpec, pTab[i].pHdr, pTab[i].pHsz))
            {Protocol = pTab[i].pVal;
-            strncpy(ProtName, pTab[i].pHdr, pTab[i].pHsz-3);
+            memcpy(ProtName, pTab[i].pHdr, pTab[i].pHsz-3);
             return;
            }
        }
```

Just wanted to make sure this is appropriate and then I can submit a pull request.

Thanks.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/xrootd/xrootd/issues/702
########################################################################
Use REPLY-ALL to reply to list

To unsubscribe from the XROOTD-DEV list, click the following link:
https://listserv.slac.stanford.edu/cgi-bin/wa?SUBED1=XROOTD-DEV&A=1