summaryrefslogtreecommitdiff
path: root/source3/smbd/mangle_hash2.c
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2002-05-14 19:30:29 +0000
committerJeremy Allison <jra@samba.org>2002-05-14 19:30:29 +0000
commit099b4889a2383b27d4d0ca4c0eb2175a0e87b67d (patch)
tree182ed6914fc9752102d18833da21082efbcbc2f1 /source3/smbd/mangle_hash2.c
parent615e6071945ebb4f89cdb897659e8f2956349a1b (diff)
downloadsamba-099b4889a2383b27d4d0ca4c0eb2175a0e87b67d.tar.gz
samba-099b4889a2383b27d4d0ca4c0eb2175a0e87b67d.tar.bz2
samba-099b4889a2383b27d4d0ca4c0eb2175a0e87b67d.zip
Removed lp_strip_dot code - ensured that mangling code treats names ending
in '.' as invalid long filenames (special treatment for '.' and '..' which are valid - yes Andrew I did this without strlen :-) :-). Jeremy. (This used to be commit 3180d8ba4ace9417033039d61d04c255da6f6a01)
Diffstat (limited to 'source3/smbd/mangle_hash2.c')
-rw-r--r--source3/smbd/mangle_hash2.c27
1 files changed, 24 insertions, 3 deletions
diff --git a/source3/smbd/mangle_hash2.c b/source3/smbd/mangle_hash2.c
index 1c8b0689a1..1d81602641 100644
--- a/source3/smbd/mangle_hash2.c
+++ b/source3/smbd/mangle_hash2.c
@@ -254,8 +254,8 @@ static BOOL is_mangled_component(const char *name)
*/
static BOOL is_mangled(const char *name)
{
- char *p;
- char *s;
+ const char *p;
+ const char *s;
M_DEBUG(0,("is_mangled %s ?\n", name));
@@ -431,17 +431,38 @@ static BOOL is_reserved_name(const char *name)
}
/*
- see if a filename is a legal long filename
+ See if a filename is a legal long filename.
+ A filename ending in a '.' is not legal unless it's "." or "..". JRA.
*/
+
static BOOL is_legal_name(const char *name)
{
+ const char *dot_pos = NULL;
+ BOOL alldots = True;
+ size_t numdots = 0;
+
while (*name) {
if (FLAG_CHECK(name[0], FLAG_ILLEGAL)) {
return False;
}
+ if (name[0] == '.') {
+ dot_pos = name;
+ numdots++;
+ } else {
+ alldots = False;
+ }
name++;
}
+ 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;
}