From: Simon Wilkinson Date: Sat, 2 Mar 2013 09:47:53 +0000 (+0000) Subject: volser: Don't overflow volume name X-Git-Tag: upstream/1.6.10_pre1^2~151 X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=fe288204f65298e494b5ea8bc031ae9c9b798364;p=packages%2Fo%2Fopenafs.git volser: Don't overflow volume name 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 Tested-by: BuildBot Reviewed-by: Jeffrey Altman (cherry picked from commit 4f9ec8396d1c7f12f8fa264cea7c255ce62b7b8d) Change-Id: I7e2dfcaf23312dde123515e2c7329df1fa62de3e Reviewed-on: http://gerrit.openafs.org/11038 Reviewed-by: Andrew Deason Tested-by: BuildBot Reviewed-by: Chas Williams - CONTRACTOR Reviewed-by: Stephan Wiesand --- diff --git a/src/volser/vsprocs.c b/src/volser/vsprocs.c index 0124bfb46..8673850a8 100644 --- a/src/volser/vsprocs.c +++ b/src/volser/vsprocs.c @@ -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