From 2daa413e3ec061e0653adbd1d6549f15e0659a62 Mon Sep 17 00:00:00 2001 From: Andrew Deason Date: Tue, 7 Aug 2018 17:27:24 -0500 Subject: [PATCH] Avoid format truncation warnings MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit With gcc 7.3, we start getting several warnings like the following: vutil.c: In function ‘VWalkVolumeHeaders’: vutil.c:860:34: error: ‘%s’ directive output may be truncated writing up to 255 bytes into a region of size 63 [-Werror=format-truncation=] snprintf(name, VMAXPATHLEN, "%s" OS_DIRSEP "%s", partpath, dentry->d_name); Most or all of these truncations should be okay, but increase the size of the relevant buffers so we can build with warning checking turned on. Change-Id: Iac62d6fcfa46f523c34bf1b0ebc2770d3d67c174 Reviewed-on: https://gerrit.openafs.org/13274 Reviewed-by: Michael Meffie Reviewed-by: Benjamin Kaduk Tested-by: BuildBot --- src/aklog/klog.c | 2 +- src/vol/voldefs.h | 2 +- src/volser/restorevol.c | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/aklog/klog.c b/src/aklog/klog.c index ebeb006..26e14c9 100644 --- a/src/aklog/klog.c +++ b/src/aklog/klog.c @@ -215,7 +215,7 @@ whoami(struct ktc_token *atoken, int *vicep) { int code; - char tempname[PR_MAXNAMELEN + 1]; + char tempname[2*PR_MAXNAMELEN]; code = pr_Initialize(0, AFSDIR_CLIENT_ETC_DIRPATH, cellconfig->name); if (code) diff --git a/src/vol/voldefs.h b/src/vol/voldefs.h index 57bebe6..8137404 100644 --- a/src/vol/voldefs.h +++ b/src/vol/voldefs.h @@ -69,7 +69,7 @@ #define VHDRNAMELEN (VFORMATDIGITS + 1 + sizeof(VHDREXT) - 1) /* must match VFORMAT */ /* Maximum length (including trailing NUL) of a volume external path name. */ -#define VMAXPATHLEN 64 +#define VMAXPATHLEN 512 #if defined(AFS_NAMEI_ENV) && !defined(AFS_NT40_ENV) diff --git a/src/volser/restorevol.c b/src/volser/restorevol.c index 0f28875..184951c 100644 --- a/src/volser/restorevol.c +++ b/src/volser/restorevol.c @@ -800,8 +800,8 @@ WorkerBee(struct cmd_syndesc *as, void *arock) afs_int32 type, count, vcount; DIR *dirP, *dirQ; struct dirent *dirE, *dirF; - char name[MAXNAMELEN]; - char thisdir[MAXPATHLEN], *t; + char name[2*MAXNAMELEN+1]; + char thisdir[MAXPATHLEN+4], *t; struct DumpHeader dh; /* Defined in dump.h */ #if 0/*ndef HAVE_GETCWD*/ /* XXX enable when autoconf happens */ extern char *getwd(); -- 1.9.4