]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
vol: Fix two buffers being one char too short
authorAnders Kaseorg <andersk@mit.edu>
Sat, 2 Sep 2017 03:37:07 +0000 (23:37 -0400)
committerBenjamin Kaduk <kaduk@mit.edu>
Wed, 27 Sep 2017 15:13:54 +0000 (11:13 -0400)
Fixes these warnings:

namei_ops.c: In function 'namei_copy_on_write':
namei_ops.c:1328:31: warning: 'snprintf' output may be truncated before the last format character [-Wformat-truncation=]
  snprintf(path, sizeof(path), "%s-tmp", name.n_path);
                               ^~~~~~~~
namei_ops.c:1328:2: note: 'snprintf' output between 5 and 260 bytes into a destination of size 259
  snprintf(path, sizeof(path), "%s-tmp", name.n_path);
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

vol_split.c: In function 'split_volume':
vol_split.c:576:22: warning: 'sprintf' may write a terminating nul past the end of the destination [-Wformat-overflow=]
     sprintf(symlink, "#%s", V_name(newvol));
                      ^~~~~
vol_split.c:576:5: note: 'sprintf' output between 2 and 33 bytes into a destination of size 32
     sprintf(symlink, "#%s", V_name(newvol));
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Reviewed-on: https://gerrit.openafs.org/12722
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
(cherry picked from commit 0a9a6b57ce6e1c97fcc651c8cb74e66fc8422a1e)

Change-Id: Ia60439aed7925b786a0213d96a7afb413579e01f
Reviewed-on: https://gerrit.openafs.org/12723
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
src/vol/namei_ops.c
src/volser/vol_split.c

index 19aea95d6f2194b35adadd47101cd901bba71173..aee57a3c3c37251cb65e13791e3091d612495d04 100644 (file)
@@ -1317,7 +1317,7 @@ namei_copy_on_write(IHandle_t *h)
     if (afs_stat(name.n_path, &tstat) < 0)
        return EIO;
     if (tstat.st_nlink > 1) {                   /* do a copy on write */
-       char path[259];
+       char path[NAMEI_PATH_LEN + 4];
        char *buf;
        afs_size_t size;
        ssize_t tlen;
index 29f5646684556e7b7d664a919812d11f0c0ec904..fa42a7ca233355992db7dec74250809e834abd39 100644 (file)
@@ -518,7 +518,7 @@ createMountpoint(Volume *vol, Volume *newvol, struct VnodeDiskObject *parent,
     AFSFid fid;
     struct timeval now;
     afs_uint32 newvN;
-    char symlink[32];
+    char symlink[VNAMESIZE + 1];
     ssize_t rc;
 
     FT_GetTimeOfDay(&now, 0);