From 418a70feedb5574d28c3fbe513333b0fb102a3ca Mon Sep 17 00:00:00 2001 From: Jeffrey Altman Date: Wed, 8 Jun 2011 02:22:41 -0400 Subject: [PATCH] Windows: shell extension is multithreaded Since the shell extension is multithreaded and it is possible for more than one thread to be executing in the gui2fs.cpp module at a time, it is not safe to use a single static 'space' buffer by more than one thread at a time. Move the buffer into the stack of each function that uses it so that we have thread safety. Change-Id: Idbec3e0027fc7e3c43b503c55c1b479bcb5984bc Reviewed-on: http://gerrit.openafs.org/4819 Tested-by: BuildBot Reviewed-by: Jeffrey Altman Tested-by: Jeffrey Altman --- src/WINNT/client_exp/gui2fs.cpp | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/src/WINNT/client_exp/gui2fs.cpp b/src/WINNT/client_exp/gui2fs.cpp index 02c0a486b..fe33753d4 100644 --- a/src/WINNT/client_exp/gui2fs.cpp +++ b/src/WINNT/client_exp/gui2fs.cpp @@ -70,9 +70,6 @@ extern "C" { #define MAXHOSTCHARS 64 #define MAXHOSTSPERCELL 8 -static char space[AFS_PIOCTL_MAXSIZE]; -static char tspace[1024]; - static struct ubik_client *uclient; static int rxInitDone = 0; static char pn[] = "fs"; @@ -282,6 +279,8 @@ WhichCell(CStringArray& files) HOURGLASS hourglass; for (int i = 0; i < files.GetSize(); i++) { + char space[AFS_PIOCTL_MAXSIZE]; + blob.in_size = 0; blob.out_size = AFS_PIOCTL_MAXSIZE; blob.out = space; @@ -309,6 +308,7 @@ WhichCell(CStringArray& files) void NO_CALLER WSCellCmd(void) { + char space[AFS_PIOCTL_MAXSIZE]; LONG code; struct ViceIoctl blob; @@ -376,6 +376,8 @@ WhereIs(CStringArray& files) HOURGLASS hourglass; for (int i = 0; i < files.GetSize(); i++) { + char space[AFS_PIOCTL_MAXSIZE]; + blob.out_size = AFS_PIOCTL_MAXSIZE; blob.in_size = 0; blob.out = space; @@ -562,6 +564,8 @@ CleanACL(CStringArray& names) HOURGLASS hourglass; for (int i = 0; i < names.GetSize(); i++) { + char space[AFS_PIOCTL_MAXSIZE]; + blob.out_size = AFS_PIOCTL_MAXSIZE; blob.in_size = 0; blob.out = space; @@ -614,7 +618,7 @@ GetRights(const CString& strDir, CStringArray& strNormal, CStringArray& strNegat struct ViceIoctl blob; struct AclEntry *te; int idf = 0; //getidf(as, parm_listacl_id); - + char space[AFS_PIOCTL_MAXSIZE]; HOURGLASS hourglass; blob.out_size = AFS_PIOCTL_MAXSIZE; @@ -812,7 +816,7 @@ CopyACL(const CString& strToDir, const CStringArray& normal, const CStringArray& struct ViceIoctl blob; struct Acl *pToAcl; int idf = 0; // getidf(as, parm_copyacl_id); - + char space[AFS_PIOCTL_MAXSIZE]; HOURGLASS hourglass; // Get ACL to copy to @@ -948,6 +952,7 @@ IsFreelanceRoot(const CString& apath) { struct ViceIoctl blob; afs_int32 code; + char space[AFS_PIOCTL_MAXSIZE]; blob.in_size = 0; blob.out_size = AFS_PIOCTL_MAXSIZE; @@ -1216,6 +1221,7 @@ ListMount(CStringArray& files) for (int i = 0; i < files.GetSize(); i++) { int last_slash = files[i].ReverseFind(_T('\\')); + char space[AFS_PIOCTL_MAXSIZE]; if (last_slash != -1) { last_component.SetString( files[i].Mid(last_slash + 1) ); @@ -1366,7 +1372,7 @@ IsSymlink(const CString& strName) { struct ViceIoctl blob; int code; - + char space[AFS_PIOCTL_MAXSIZE]; HOURGLASS hourglass; CStringUtf8 ustrLast(LastComponent(strName)); @@ -1484,7 +1490,7 @@ GetVolumeInfo(CString strFile, CVolInfo& volInfo) struct ViceIoctl blob; struct VolumeStatus *status; char *name; - + char space[AFS_PIOCTL_MAXSIZE]; HOURGLASS hourglass; volInfo.m_strFilePath = strFile; @@ -1534,7 +1540,7 @@ SetVolInfo(CVolInfo& volInfo) struct ViceIoctl blob; struct VolumeStatus *status; char *input; - + char space[AFS_PIOCTL_MAXSIZE]; HOURGLASS hourglass; blob.out_size = AFS_PIOCTL_MAXSIZE; @@ -1592,7 +1598,7 @@ CheckServers(const CString& strCellName, WHICH_CELLS nCellsToCheck, BOOL bFast) LONG temp = 0; struct afsconf_cell info; struct chservinfo checkserv; - + char space[AFS_PIOCTL_MAXSIZE]; HOURGLASS hourglass; memset(&checkserv, 0, sizeof(struct chservinfo)); @@ -1796,7 +1802,7 @@ ListSymbolicLinkPath(const char *strName,char *strPath,UINT nlenPath) char parent_dir[MAX_PATH+1]; /*Parent directory of true name*/ char *last_component; /*Last component of true name*/ UINT code; - + char space[AFS_PIOCTL_MAXSIZE]; HOURGLASS hourglass; strcpy(orig_name, strName); @@ -1857,7 +1863,7 @@ ListSymlink(CStringArray& files) struct ViceIoctl blob; int error; CStringArray symlinks; - + char space[AFS_PIOCTL_MAXSIZE]; HOURGLASS hourglass; error = 0; -- 2.39.5