svn commit: samba r2928 - in branches/SAMBA_4_0/source/ntvfs/posix: .

tridge at samba.org tridge at samba.org
Tue Oct 12 05:33:06 GMT 2004


Author: tridge
Date: 2004-10-12 05:33:05 +0000 (Tue, 12 Oct 2004)
New Revision: 2928

WebSVN: http://websvn.samba.org/websvn/changeset.php?rep=samba&path=/branches/SAMBA_4_0/source/ntvfs/posix&rev=2928&nolog=1

Log:
- fixed the handling of reserved names (rejecting them with ACCESS_DENIED)

- don't check for '.' specially in checking for legal names. Longhorn
  doesn't do this any more, and its a real pain. Longhorn allows for
  filenames ending in '.', and with as many '.' elements as you like.


Modified:
   branches/SAMBA_4_0/source/ntvfs/posix/pvfs_resolve.c
   branches/SAMBA_4_0/source/ntvfs/posix/pvfs_shortname.c
   branches/SAMBA_4_0/source/ntvfs/posix/vfs_posix.h


Changeset:
Modified: branches/SAMBA_4_0/source/ntvfs/posix/pvfs_resolve.c
===================================================================
--- branches/SAMBA_4_0/source/ntvfs/posix/pvfs_resolve.c	2004-10-12 05:10:43 UTC (rev 2927)
+++ branches/SAMBA_4_0/source/ntvfs/posix/pvfs_resolve.c	2004-10-12 05:33:05 UTC (rev 2928)
@@ -84,6 +84,9 @@
 		components[i] = p;
 		p = strchr(p, '/');
 		if (p) *p++ = 0;
+		if (pvfs_is_reserved_name(pvfs, components[i])) {
+			return NT_STATUS_ACCESS_DENIED;
+		}
 	}
 
 	partial_name = talloc_strdup(name, components[0]);

Modified: branches/SAMBA_4_0/source/ntvfs/posix/pvfs_shortname.c
===================================================================
--- branches/SAMBA_4_0/source/ntvfs/posix/pvfs_shortname.c	2004-10-12 05:10:43 UTC (rev 2927)
+++ branches/SAMBA_4_0/source/ntvfs/posix/pvfs_shortname.c	2004-10-12 05:33:05 UTC (rev 2928)
@@ -93,7 +93,11 @@
 
 #define FLAG_CHECK(c, flag) (ctx->char_flags[(uint8_t)(c)] & (flag))
 
+static const char *reserved_names[] = 
+{ "AUX", "CON", "COM1", "COM2", "COM3", "COM4",
+  "LPT1", "LPT2", "LPT3", "NUL", "PRN", NULL };
 
+
 /* 
    hash a string of the specified length. The string does not need to be
    null terminated 
@@ -367,11 +371,8 @@
 	    FLAG_CHECK(name[3], FLAG_POSSIBLE4)) {
 		/* a likely match, scan the lot */
 		int i;
-		for (i=0; ctx->reserved_names[i]; i++) {
-			int len = strlen(ctx->reserved_names[i]);
-			/* note that we match on COM1 as well as COM1.foo */
-			if (strncasecmp(name, ctx->reserved_names[i], len) == 0 &&
-			    (name[len] == '.' || name[len] == 0)) {
+		for (i=0; reserved_names[i]; i++) {
+			if (strcasecmp(name, reserved_names[i]) == 0) {
 				return True;
 			}
 		}
@@ -387,10 +388,6 @@
 */
 static BOOL is_legal_name(struct pvfs_mangle_context *ctx, const char *name)
 {
-	const char *dot_pos = NULL;
-	BOOL alldots = True;
-	size_t numdots = 0;
-
 	while (*name) {
 		size_t c_size;
 		codepoint_t c = next_codepoint(name, &c_size);
@@ -405,25 +402,9 @@
 		if (FLAG_CHECK(c, FLAG_ILLEGAL)) {
 			return False;
 		}
-		if (name[0] == '.') {
-			dot_pos = name;
-			numdots++;
-		} else {
-			alldots = False;
-		}
-
 		name += c_size;
 	}
 
-	if (dot_pos) {
-		if (alldots && (numdots == 1 || numdots == 2))
-			return True; /* . or .. is a valid name */
-
-		/* A valid long name cannot end in '.' */
-		if (dot_pos[1] == '\0')
-			return False;
-	}
-
 	return True;
 }
 
@@ -567,11 +548,7 @@
 	const char *basechars = MANGLE_BASECHARS;
 	int i;
 	/* the list of reserved dos names - all of these are illegal */
-	const char *reserved_names[] = 
-		{ "AUX", "LOCK$", "CON", "COM1", "COM2", "COM3", "COM4",
-		  "LPT1", "LPT2", "LPT3", "NUL", "PRN", NULL };
 
-
 	ZERO_STRUCT(ctx->char_flags);
 
 	for (i=1;i<128;i++) {
@@ -598,17 +575,15 @@
 		ctx->base_reverse[(uint8_t)basechars[i]] = i;
 	}	
 
-	ctx->reserved_names = reserved_names;
-
 	/* fill in the reserved names flags. These are used as a very
 	   fast filter for finding possible DOS reserved filenames */
-	for (i=0; ctx->reserved_names[i]; i++) {
+	for (i=0; reserved_names[i]; i++) {
 		unsigned char c1, c2, c3, c4;
 
-		c1 = (unsigned char)ctx->reserved_names[i][0];
-		c2 = (unsigned char)ctx->reserved_names[i][1];
-		c3 = (unsigned char)ctx->reserved_names[i][2];
-		c4 = (unsigned char)ctx->reserved_names[i][3];
+		c1 = (unsigned char)reserved_names[i][0];
+		c2 = (unsigned char)reserved_names[i][1];
+		c3 = (unsigned char)reserved_names[i][2];
+		c4 = (unsigned char)reserved_names[i][3];
 
 		ctx->char_flags[c1] |= FLAG_POSSIBLE1;
 		ctx->char_flags[c2] |= FLAG_POSSIBLE2;
@@ -702,3 +677,12 @@
 	}
 	return NULL;
 }
+
+
+/*
+  look for a DOS reserved name
+*/
+BOOL pvfs_is_reserved_name(struct pvfs_state *pvfs, const char *name)
+{
+	return is_reserved_name(pvfs->mangle_ctx, name);
+}

Modified: branches/SAMBA_4_0/source/ntvfs/posix/vfs_posix.h
===================================================================
--- branches/SAMBA_4_0/source/ntvfs/posix/vfs_posix.h	2004-10-12 05:10:43 UTC (rev 2927)
+++ branches/SAMBA_4_0/source/ntvfs/posix/vfs_posix.h	2004-10-12 05:33:05 UTC (rev 2928)
@@ -138,8 +138,6 @@
 
 	/* this is used to reverse the base 36 mapping */
 	unsigned char base_reverse[256];
-
-	const char **reserved_names;
 };
 
 



More information about the samba-cvs mailing list