From: Benjamin Kaduk Date: Sat, 2 Feb 2019 21:26:23 +0000 (-0600) Subject: uss: Allocate buffer space for trailing NUL X-Git-Tag: upstream/1.8.6_pre1^2~45 X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=d38a136c1343d62243b738afd6dc5b72cc3e6ae1;p=packages%2Fo%2Fopenafs.git uss: Allocate buffer space for trailing NUL Appease gcc8's -Wformat-truncation engine. Reviewed-on: https://gerrit.openafs.org/13467 Tested-by: BuildBot Reviewed-by: Cheyenne Wills Reviewed-by: Michael Meffie Reviewed-by: Benjamin Kaduk (cherry picked from commit 9a5ba85d1853327d8184287e58a6e03fabaaf23d) Change-Id: I9900452b951d600e6358b216015fe4fcdf8f633e Reviewed-on: https://gerrit.openafs.org/13736 Reviewed-by: Andrew Deason Reviewed-by: Marcio Brito Barbosa Reviewed-by: Michael Meffie Tested-by: BuildBot Reviewed-by: Stephan Wiesand --- diff --git a/src/uss/uss_procs.c b/src/uss/uss_procs.c index 28fa78484..d7d4ad8bc 100644 --- a/src/uss/uss_procs.c +++ b/src/uss/uss_procs.c @@ -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,