svn commit: samba r22010 - in branches/SAMBA_3_0/source/smbd: .

jra at samba.org jra at samba.org
Thu Mar 29 19:40:59 GMT 2007


Author: jra
Date: 2007-03-29 19:40:59 +0000 (Thu, 29 Mar 2007)
New Revision: 22010

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

Log:
Now I'm looking at mangling again, make sure
that we mangle any illegal names before doing
any wildcard matches. That way lies least
suprises. Don't merge this for 3.0.25, too
dangerous. Thanks.
Jeremy.

Modified:
   branches/SAMBA_3_0/source/smbd/trans2.c


Changeset:
Modified: branches/SAMBA_3_0/source/smbd/trans2.c
===================================================================
--- branches/SAMBA_3_0/source/smbd/trans2.c	2007-03-29 09:35:51 UTC (rev 22009)
+++ branches/SAMBA_3_0/source/smbd/trans2.c	2007-03-29 19:40:59 UTC (rev 22010)
@@ -1160,16 +1160,28 @@
 		DEBUG(8,("get_lanman2_dir_entry:readdir on dirptr 0x%lx now at offset %ld\n",
 			(long)conn->dirptr,curr_dirpos));
       
-		if (!dname) 
+		if (!dname) {
 			return(False);
+		}
 
+		/*
+		 * fname may get mangled, dname is never mangled.
+		 * Whenever we're accessing the filesystem we use
+		 * pathreal which is composed from dname.
+		 */
+
 		pstrcpy(fname,dname);      
 
-		if(!(got_match = *got_exact_match = exact_match(conn, fname, mask)))
+		/* This will mangle fname if it's an illegal name. */
+		mangle_map(fname,False,True,conn->params);
+
+		if(!(got_match = *got_exact_match = exact_match(conn, fname, mask))) {
 			got_match = mask_match(fname, mask, conn->case_sensitive);
+		}
 
 		if(!got_match && check_mangled_names &&
 		   !mangle_is_8_3(fname, False, conn->params)) {
+			pstring mangled_name;
 
 			/*
 			 * It turns out that NT matches wildcards against
@@ -1178,21 +1190,25 @@
 			 * that some people have been seeing.... JRA.
 			 */
 
-			pstring newname;
-			pstrcpy( newname, fname);
-			mangle_map( newname, True, False, conn->params);
-			if(!(got_match = *got_exact_match = exact_match(conn, newname, mask)))
-				got_match = mask_match(newname, mask, conn->case_sensitive);
+			pstrcpy(mangled_name, fname);
+
+			/* Force the mangling into 8.3. */
+			mangle_map( mangled_name, True, False, conn->params);
+			if(!(got_match = *got_exact_match = exact_match(conn, mangled_name, mask))) {
+				got_match = mask_match(mangled_name, mask, conn->case_sensitive);
+			}
 		}
 
-		if(got_match) {
-			BOOL isdots = (strequal(fname,"..") || strequal(fname,"."));
-			if (dont_descend && !isdots)
+		if (got_match) {
+			BOOL isdots = (strequal(dname,"..") || strequal(dname,"."));
+			if (dont_descend && !isdots) {
 				continue;
+			}
 	  
 			pstrcpy(pathreal,conn->dirpath);
-			if(needslash)
+			if(needslash) {
 				pstrcat(pathreal,"/");
+			}
 			pstrcat(pathreal,dname);
 
 			if (INFO_LEVEL_IS_UNIX(info_level)) {
@@ -1230,12 +1246,13 @@
 			}
 
 			if (!dir_check_ftype(conn,mode,dirtype)) {
-				DEBUG(5,("[%s] attribs didn't match %x\n",fname,dirtype));
+				DEBUG(5,("get_lanman2_dir_entry: [%s] attribs didn't match %x\n",fname,dirtype));
 				continue;
 			}
 
-			if (!(mode & aDIR))
+			if (!(mode & aDIR)) {
 				file_size = get_file_size(sbuf);
+			}
 			allocation_size = get_allocation_size(conn,NULL,&sbuf);
 
 			mdate_ts = get_mtimespec(&sbuf);
@@ -1252,7 +1269,7 @@
 			mdate = convert_timespec_to_time_t(mdate_ts);
 			adate = convert_timespec_to_time_t(adate_ts);
 			
-			DEBUG(5,("get_lanman2_dir_entry found %s fname=%s\n",pathreal,fname));
+			DEBUG(5,("get_lanman2_dir_entry: found %s fname=%s\n",pathreal,fname));
 	  
 			found = True;
 
@@ -1260,8 +1277,6 @@
 		}
 	}
 
-	mangle_map(fname,False,True,conn->params);
-
 	p = pdata;
 	last_entry_ptr = p;
 



More information about the samba-cvs mailing list