Avoid gcc warning 13/12813/4
authorChristof Hanke <christof.hanke@rzg.mpg.de>
Mon, 18 Dec 2017 15:58:39 +0000 (16:58 +0100)
committerBenjamin Kaduk <kaduk@mit.edu>
Tue, 19 Dec 2017 04:37:22 +0000 (23:37 -0500)
When using the configure option --enable-checking with gcc 7.2.1,
the compilation fails with

vutil.c:860:20: error: ā€˜%sā€™ directive writing up to 255 bytes into \
a region of size 63 [-Werror=format-overflow=]

This can be seen in the logs of the openSUSE Tumbleweed builder
for e.g. build 2368.
Avoid this warning by using snprintf which is provided by libroken
for all platforms.

Change-Id: I6acd3a1c06760abc8144c0892812c3bb50477227
Reviewed-on: https://gerrit.openafs.org/12813
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

src/vol/vutil.c

index c7c7a8d..cafed4d 100644 (file)
@@ -857,7 +857,7 @@ VWalkVolumeHeaders(struct DiskPartition64 *dp, const char *partpath,
        if (p != NULL && strcmp(p, VHDREXT) == 0) {
            char name[VMAXPATHLEN];
 
-           sprintf(name, "%s" OS_DIRSEP "%s", partpath, dentry->d_name);
+           snprintf(name, VMAXPATHLEN, "%s" OS_DIRSEP "%s", partpath, dentry->d_name);
 
            code = _VHandleVolumeHeader(dp, volfunc, name, &diskHeader, -1, rock);
            if (code < 0) {