From: Jeffrey Altman Date: Fri, 15 Mar 2013 17:07:21 +0000 (-0400) Subject: Windows: drive mapping enumeration infinite loop X-Git-Tag: upstream/1.8.0_pre1^2~1295 X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=e5966117c4f0db631e0e25fc27f63e4caa76fa23;p=packages%2Fo%2Fopenafs.git Windows: drive mapping enumeration infinite loop If WNetEnumResource returns an error as opposed to success, such as ERROR_UNEXP_NET_ERR, the enumeration loop would retry forever passing zero for 'cEntries' which in turn results in a successful response containing zero entries. Change the while conditional to test for continued success instead of ERROR_NO_MORE_ENTRIES. Change-Id: I93af73b379aa455de7a8b3264b5178d482bb52b0 Reviewed-on: http://gerrit.openafs.org/9610 Tested-by: BuildBot Reviewed-by: Jeffrey Altman Tested-by: Jeffrey Altman --- diff --git a/src/WINNT/client_config/drivemap.cpp b/src/WINNT/client_config/drivemap.cpp index 9e1a7da38..cb9a9a21a 100644 --- a/src/WINNT/client_config/drivemap.cpp +++ b/src/WINNT/client_config/drivemap.cpp @@ -1197,7 +1197,10 @@ void DoUnMapShare(BOOL drivemap) //disconnect drivemap _strlwr(szPath); lpnrLocal=(LPNETRESOURCE) GlobalAlloc(GPTR,cbBuffer); do { + /* Reset lpnrLocal and cEntries before each call */ memset(lpnrLocal,0,cbBuffer); + cEntries = -1; + if ((res = WNetEnumResource(hEnum,&cEntries,lpnrLocal,&cbBuffer))==NO_ERROR) { for (DWORD i=0;i