svn commit: samba r21759 - in branches: SAMBA_3_0/source/smbd SAMBA_3_0_25/source/smbd

jra at samba.org jra at samba.org
Thu Mar 8 03:00:43 GMT 2007


Author: jra
Date: 2007-03-08 03:00:42 +0000 (Thu, 08 Mar 2007)
New Revision: 21759

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

Log:
Fix the same bug in a more elegant way, strrchr_m
is an expensive call....
Jeremy.

Modified:
   branches/SAMBA_3_0/source/smbd/msdfs.c
   branches/SAMBA_3_0_25/source/smbd/msdfs.c


Changeset:
Modified: branches/SAMBA_3_0/source/smbd/msdfs.c
===================================================================
--- branches/SAMBA_3_0/source/smbd/msdfs.c	2007-03-08 02:51:41 UTC (rev 21758)
+++ branches/SAMBA_3_0/source/smbd/msdfs.c	2007-03-08 03:00:42 UTC (rev 21759)
@@ -331,6 +331,7 @@
 	SMB_STRUCT_STAT sbuf;
 	NTSTATUS status;
 	pstring reqpath;
+	pstring local_dfspath;
 
 	if (!dp || !conn) {
 		DEBUG(1,("resolve_dfs_path: NULL dfs_path* or NULL connection_struct*!\n"));
@@ -385,6 +386,12 @@
 		return True;
 	}
 
+	/* Prepare to test only for '/' components in the given path,
+	 * so replace all '\\' characters with '/'. */
+
+	pstrcpy(local_dfspath, dfspath);
+	string_replace(local_dfspath, '\\', '/');
+
 	/* redirect if any component in the path is a link */
 	pstrcpy(reqpath, localpath);
 	p = strrchr_m(reqpath, '/');
@@ -402,14 +409,12 @@
 			
 			if (consumedcntp) {
 				pstring buf;
-				pstrcpy(buf, dfspath);
-				trim_char(buf, '\0', '\\');
+				pstrcpy(buf, local_dfspath);
+				trim_char(buf, '\0', '/');
 				for (; consumed_level; consumed_level--) {
-					char *q, *q1, *q2;
-					/* Either '\\' or '/' may be a separator. */
-					q1 = strrchr_m(buf, '\\');
-					q2 = strrchr_m(buf, '/');
-					q = MAX(q1,q2);
+					char *q;
+					/* We made sure only '/' may be a separator above. */
+					q = strrchr_m(buf, '/');
 					if (q) {
 						*q = 0;
 					}

Modified: branches/SAMBA_3_0_25/source/smbd/msdfs.c
===================================================================
--- branches/SAMBA_3_0_25/source/smbd/msdfs.c	2007-03-08 02:51:41 UTC (rev 21758)
+++ branches/SAMBA_3_0_25/source/smbd/msdfs.c	2007-03-08 03:00:42 UTC (rev 21759)
@@ -331,6 +331,7 @@
 	SMB_STRUCT_STAT sbuf;
 	NTSTATUS status;
 	pstring reqpath;
+	pstring local_dfspath;
 
 	if (!dp || !conn) {
 		DEBUG(1,("resolve_dfs_path: NULL dfs_path* or NULL connection_struct*!\n"));
@@ -385,6 +386,12 @@
 		return True;
 	}
 
+	/* Prepare to test only for '/' components in the given path,
+	 * so replace all '\\' characters with '/'. */
+
+	pstrcpy(local_dfspath, dfspath);
+	string_replace(local_dfspath, '\\', '/');
+
 	/* redirect if any component in the path is a link */
 	pstrcpy(reqpath, localpath);
 	p = strrchr_m(reqpath, '/');
@@ -402,14 +409,12 @@
 			
 			if (consumedcntp) {
 				pstring buf;
-				pstrcpy(buf, dfspath);
-				trim_char(buf, '\0', '\\');
+				pstrcpy(buf, local_dfspath);
+				trim_char(buf, '\0', '/');
 				for (; consumed_level; consumed_level--) {
-					char *q, *q1, *q2;
-					/* Either '\\' or '/' may be a separator. */
-					q1 = strrchr_m(buf, '\\');
-					q2 = strrchr_m(buf, '/');
-					q = MAX(q1,q2);
+					char *q;
+					/* We made sure only '/' may be a separator above. */
+					q = strrchr_m(buf, '/');
 					if (q) {
 						*q = 0;
 					}



More information about the samba-cvs mailing list