uss: Allocate buffer space for trailing NUL 67/13467/2
authorBenjamin Kaduk <kaduk@mit.edu>
Sat, 2 Feb 2019 21:26:23 +0000 (15:26 -0600)
committerBenjamin Kaduk <kaduk@mit.edu>
Fri, 1 Mar 2019 13:22:08 +0000 (08:22 -0500)
Appease gcc8's -Wformat-truncation engine.

Change-Id: I2113770f63357edf0f5ca273daf0c516a72034a8
Reviewed-on: https://gerrit.openafs.org/13467
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

src/uss/uss_procs.c

index 4e48071..ae248af 100644 (file)
@@ -664,7 +664,7 @@ uss_procs_PickADir(char *path, char *cp)
     int i, count, MinIndex = 0, mina = 10000;
     struct dirent *dp;
     DIR *dirp;
-    char dirname[300];
+    char dirname[301];
 
     if (uss_NumGroups == 0) {
        fprintf(stderr, "%s: No choice yet given to replace $AUTO\n",
@@ -698,7 +698,7 @@ uss_procs_PickADir(char *path, char *cp)
      * each and pick the minimum.
      */
     for (i = 0; i < uss_NumGroups; i++) {
-       sprintf(dirname, "%s/%s", cd, uss_DirPool[i]);
+       snprintf(dirname, sizeof(dirname), "%s/%s", cd, uss_DirPool[i]);
        if ((dirp = opendir(dirname)) == NULL) {
            if (errno != ENOTDIR)
                fprintf(stderr,