svn commit: samba r5631 - in trunk/source/smbd: .

jra at samba.org jra at samba.org
Thu Mar 3 02:04:34 GMT 2005


Author: jra
Date: 2005-03-03 02:04:34 +0000 (Thu, 03 Mar 2005)
New Revision: 5631

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=5631

Log:
Fix infinite looping bug found by nasty BlueArc test :-).
When finding a singleton directory remember that we're
at the end and don't continuously return the same name.
Jeremy.

Modified:
   trunk/source/smbd/dir.c


Changeset:
Modified: trunk/source/smbd/dir.c
===================================================================
--- trunk/source/smbd/dir.c	2005-03-02 21:43:54 UTC (rev 5630)
+++ trunk/source/smbd/dir.c	2005-03-03 02:04:34 UTC (rev 5631)
@@ -525,10 +525,17 @@
 	pstring pathreal;
 
 	ZERO_STRUCTP(pst);
+
 	if (dptr->has_wild) {
 		return dptr_normal_ReadDirName(dptr, poffset, pst);
 	}
 
+	/* If poffset is -1 then we know we returned this name before and we have
+	   no wildcards. We're at the end of the directory. */
+	if (*poffset == -1) {
+		return NULL;
+	}
+
 	/* We know the stored wcard contains no wildcard characters. See if we can match
 	   with a stat call. If we can't, then set has_wild to true to
 	   prevent us from doing this on every call. */
@@ -540,6 +547,9 @@
 	}
 
 	if (VALID_STAT(*pst)) {
+		/* We need to set the underlying dir_hdn offset to -1 also as
+		   this function is usually called with the output from TellDir. */
+		dptr->dir_hnd->offset = *poffset = -1;
 		return dptr->wcard;
 	}
 
@@ -548,11 +558,17 @@
 	pstrcat(pathreal,dptr->wcard);
 
 	if (SMB_VFS_STAT(dptr->conn,pathreal,pst) == 0) {
+		/* We need to set the underlying dir_hdn offset to -1 also as
+		   this function is usually called with the output from TellDir. */
+		dptr->dir_hnd->offset = *poffset = -1;
 		return dptr->wcard;
 	} else {
 		/* If we get any other error than ENOENT or ENOTDIR
 		   then the file exists we just can't stat it. */
 		if (errno != ENOENT && errno != ENOTDIR) {
+			/* We need to set the underlying dir_hdn offset to -1 also as
+			   this function is usually called with the output from TellDir. */
+			dptr->dir_hnd->offset = *poffset = -1;
 			return dptr->wcard;
 		}
 	}
@@ -563,6 +579,9 @@
 	   with a stat we will fail. */
 
 	if (dptr->conn->case_sensitive) {
+		/* We need to set the underlying dir_hdn offset to -1 also as
+		   this function is usually called with the output from TellDir. */
+		dptr->dir_hnd->offset = *poffset = -1;
 		return NULL;
 	} else {
 		return dptr_normal_ReadDirName(dptr, poffset, pst);
@@ -1033,6 +1052,7 @@
 		*poffset = e->offset= dirp->offset;
 		return e->name;
 	}
+	dirp->offset = -1;
 	return NULL;
 }
 



More information about the samba-cvs mailing list