]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
volser: Don't overflow volume name
authorSimon Wilkinson <sxw@your-file-system.com>
Sat, 2 Mar 2013 09:47:53 +0000 (09:47 +0000)
committerStephan Wiesand <stephan.wiesand@desy.de>
Tue, 3 Jun 2014 16:36:18 +0000 (12:36 -0400)
The maximum volume name length in the VLDB RPCs is VL_MAXNAMELEN
(65), not 64 as used as a hardcoded value in vsprocs. Switch to
using the defined value, and also use strlcat to check that we
don't overflow this.

Caught by coverity (#985849)

Reviewed-on: http://gerrit.openafs.org/9352
Reviewed-by: Derrick Brashear <shadow@your-file-system.com>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
(cherry picked from commit 4f9ec8396d1c7f12f8fa264cea7c255ce62b7b8d)

Change-Id: I7e2dfcaf23312dde123515e2c7329df1fa62de3e
Reviewed-on: http://gerrit.openafs.org/11038
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Chas Williams - CONTRACTOR <chas@cmf.nrl.navy.mil>
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
src/volser/vsprocs.c

index 0124bfb4645bcc55cc6054c1a97473d31a4b6034..8673850a8fc5223e2d2ea2af147812281a5f7f15 100644 (file)
@@ -3065,7 +3065,7 @@ GetTrans(struct nvldbentry *vldbEntryPtr, afs_int32 index,
 
     /* If the volume does not exist, create it */
     if (!volid || code) {
-       char volname[64];
+       char volname[VL_MAXNAMELEN];
         char hoststr[16];
 
        if (volid && (code != VNOVOL)) {
@@ -3074,7 +3074,16 @@ GetTrans(struct nvldbentry *vldbEntryPtr, afs_int32 index,
            goto fail;
        }
 
-       strcpy(volname, vldbEntryPtr->name);
+       strlcpy(volname, vldbEntryPtr->name, sizeof(volname));
+
+       if (strlcat(volname,
+                   tmpVolId?".roclone":".readonly",
+                   sizeof(volname)) >= sizeof(volname)) {
+           code = ENOMEM;
+           PrintError("Volume name is too long\n", code);
+           goto fail;
+       }
+
        if (tmpVolId)
            strcat(volname, ".roclone");
        else