From 4f9ec8396d1c7f12f8fa264cea7c255ce62b7b8d Mon Sep 17 00:00:00 2001 From: Simon Wilkinson Date: Sat, 2 Mar 2013 09:47:53 +0000 Subject: [PATCH] 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) Change-Id: I860d4bd4ed9a22185f4a83408d163ce20d21e751 Reviewed-on: http://gerrit.openafs.org/9352 Reviewed-by: Derrick Brashear Tested-by: BuildBot Reviewed-by: Jeffrey Altman --- src/volser/vsprocs.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/volser/vsprocs.c b/src/volser/vsprocs.c index 7af0d9ffdd..043aa42b55 100644 --- a/src/volser/vsprocs.c +++ b/src/volser/vsprocs.c @@ -3014,7 +3014,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)) { @@ -3023,7 +3023,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