From 742f1077c7e85f8d449289d72885899c0c996fcc Mon Sep 17 00:00:00 2001 From: Jeffrey Altman Date: Thu, 23 Aug 2007 21:43:08 +0000 Subject: [PATCH] DEVEL15-windows-recursion-fix-20070823 for . and .. find the last time we saw the fid in the list instead of moving back a fixed count since the parent might be a symlink or a mount point or both (cherry picked from commit e5ec3ad4fc7009fec4a0760738a6b23c250d5d83) --- src/WINNT/afsd/cm_vnodeops.c | 40 +++++++++++++++++++++--------------- 1 file changed, 24 insertions(+), 16 deletions(-) diff --git a/src/WINNT/afsd/cm_vnodeops.c b/src/WINNT/afsd/cm_vnodeops.c index 877fdd042..ac8bcac9e 100644 --- a/src/WINNT/afsd/cm_vnodeops.c +++ b/src/WINNT/afsd/cm_vnodeops.c @@ -1857,24 +1857,32 @@ long cm_NameI(cm_scache_t *rootSCachep, char *pathp, long flags, userp, reqp, &nscp); if (code == 0) { - if (!strcmp(component,"..")) - fid_count -=2; - else if (!strcmp(component,".")) - fid_count -=1; - for ( i=0; ifid, &fids[i]) ) { - code = CM_ERROR_TOO_MANY_SYMLINKS; - cm_ReleaseSCache(nscp); - nscp = NULL; - break; + if (!strcmp(component,"..") || !strcmp(component,".")) { + /* + * roll back the fid list until we find the fid + * that matches where we are now. Its not necessarily + * one or two fids because they might have been + * symlinks or mount points or both that were crossed. + */ + for ( i=fid_count-1; i>=0; i--) { + if (!cm_FidCmp(&nscp->fid, &fids[i])) + break; + } + } else { + /* add the new fid to the list */ + for ( i=0; ifid, &fids[i]) ) { + code = CM_ERROR_TOO_MANY_SYMLINKS; + cm_ReleaseSCache(nscp); + nscp = NULL; + break; + } + } + if (i == fid_count && fid_count < MAX_FID_COUNT) { + fids[fid_count++] = nscp->fid; } } - if (i == fid_count && fid_count < MAX_FID_COUNT) { - fids[fid_count++] = nscp->fid; - } - } - - if (code) { + } else { cm_ReleaseSCache(tscp); if (dirScp) cm_ReleaseSCache(dirScp); -- 2.39.5