From 06f0b6022342879c5519ff1bd0f272e1bff4538a Mon Sep 17 00:00:00 2001 From: Simon Wilkinson Date: Sat, 2 Mar 2013 09:47:53 +0000 Subject: [PATCH] libadmin: 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/9353 Reviewed-by: Derrick Brashear Tested-by: BuildBot Reviewed-by: Jeffrey Altman (cherry picked from commit 79abe9d68ea041a2ea6261c6f7bb1f055a45bf0a) Change-Id: I0e1dd46be835e74fc43335606bf5ab8341678251 Reviewed-on: http://gerrit.openafs.org/11040 Reviewed-by: Andrew Deason Tested-by: BuildBot Reviewed-by: Chas Williams - CONTRACTOR Reviewed-by: Stephan Wiesand --- src/libadmin/vos/vsprocs.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/libadmin/vos/vsprocs.c b/src/libadmin/vos/vsprocs.c index 6b016f08d..060cbf2a2 100644 --- a/src/libadmin/vos/vsprocs.c +++ b/src/libadmin/vos/vsprocs.c @@ -1328,14 +1328,18 @@ GetTrans(afs_cell_handle_p cellHandle, struct nvldbentry *vldbEntryPtr, /* If the volume does not exist, create it */ if (!volid || tst) { - char volname[64]; + char volname[VL_MAXNAMELEN]; if (volid && (tst != VNOVOL)) { goto fail_GetTrans; } - strcpy(volname, vldbEntryPtr->name); - strcat(volname, ".readonly"); + strlcpy(volname, vldbEntryPtr->name, sizeof(volname)); + if (strlcat(volname, ".readonly", sizeof(volname)) + >= sizeof(volname)) { + tst = ENOMEM; + goto fail_GetTrans; + } tst = AFSVolCreateVolume(*connPtr, vldbEntryPtr->serverPartition[index], -- 2.39.5