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

jra at samba.org jra at samba.org
Thu Sep 29 01:27:41 GMT 2005


Author: jra
Date: 2005-09-29 01:27:40 +0000 (Thu, 29 Sep 2005)
New Revision: 10601

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

Log:
Fix bug #2769 (mangle filenames ending in a space)
and an old bug where mangle mathod hash wasn't mangling
file names with more than one dot which also end in a dot.
Jeremy.

Modified:
   trunk/source/smbd/mangle_hash.c
   trunk/source/smbd/mangle_hash2.c


Changeset:
Modified: trunk/source/smbd/mangle_hash.c
===================================================================
--- trunk/source/smbd/mangle_hash.c	2005-09-29 01:27:19 UTC (rev 10600)
+++ trunk/source/smbd/mangle_hash.c	2005-09-29 01:27:40 UTC (rev 10601)
@@ -158,6 +158,7 @@
 static NTSTATUS is_valid_name(const smb_ucs2_t *fname, BOOL allow_wildcards, BOOL only_8_3)
 {
 	smb_ucs2_t *str, *p;
+	size_t num_ucs2_chars;
 	NTSTATUS ret = NT_STATUS_OK;
 
 	if (!fname || !*fname)
@@ -177,17 +178,22 @@
 	if (!NT_STATUS_IS_OK(ret))
 		return ret;
 
+	/* Name can't end in '.' or ' ' */
+	num_ucs2_chars = strlen_w(fname);
+	if (fname[num_ucs2_chars-1] == UCS2_CHAR('.') || fname[num_ucs2_chars-1] == UCS2_CHAR(' ')) {
+		return NT_STATUS_UNSUCCESSFUL;
+	}
+
 	str = strdup_w(fname);
+
+	/* Truncate copy after the first dot. */
 	p = strchr_w(str, UCS2_CHAR('.'));
-	if (p && p[1] == UCS2_CHAR(0)) {
-		/* Name cannot end in '.' */
-		SAFE_FREE(str);
-		return NT_STATUS_UNSUCCESSFUL;
+	if (p) {
+		*p = 0;
 	}
-	if (p)
-		*p = 0;
+
 	strupper_w(str);
-	p = &(str[1]);
+	p = &str[1];
 
 	switch(str[0])
 	{

Modified: trunk/source/smbd/mangle_hash2.c
===================================================================
--- trunk/source/smbd/mangle_hash2.c	2005-09-29 01:27:19 UTC (rev 10600)
+++ trunk/source/smbd/mangle_hash2.c	2005-09-29 01:27:40 UTC (rev 10601)
@@ -445,6 +445,7 @@
 /*
  See if a filename is a legal long filename.
  A filename ending in a '.' is not legal unless it's "." or "..". JRA.
+ A filename ending in ' ' is not legal either. See bug id #2769.
 */
 
 static BOOL is_legal_name(const char *name)
@@ -480,6 +481,10 @@
 		} else {
 			alldots = False;
 		}
+		if ((name[0] == ' ') && (name[1] == '\0')) {
+			/* Can't end in ' ' */
+			return False;
+		}
 		name++;
 	}
 
@@ -491,7 +496,6 @@
 		if (dot_pos[1] == '\0')
 			return False;
 	}
-
 	return True;
 }
 



More information about the samba-cvs mailing list