summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2002-04-18 02:13:55 +0000
committerAndrew Tridgell <tridge@samba.org>2002-04-18 02:13:55 +0000
commit5b8135e038b2d6b130219e39b8e88cc242604cab (patch)
treea65908a27480ba0fb220103b9e8c4e0474c200a7
parente9be6c4db4ad5a5caefed5a97df13880ca3262f4 (diff)
downloadsamba-5b8135e038b2d6b130219e39b8e88cc242604cab.tar.gz
samba-5b8135e038b2d6b130219e39b8e88cc242604cab.tar.bz2
samba-5b8135e038b2d6b130219e39b8e88cc242604cab.zip
- fixed the is_mangled() interface to handle multiple components
- fixed the no-extension case of reverse mangling (This used to be commit 64a2ae5cee4ffc5ae3c902705b6e1050f649e3a5)
-rw-r--r--source3/smbd/mangle_hash2.c47
1 files changed, 42 insertions, 5 deletions
diff --git a/source3/smbd/mangle_hash2.c b/source3/smbd/mangle_hash2.c
index 959a93e07b..5b3c63ec55 100644
--- a/source3/smbd/mangle_hash2.c
+++ b/source3/smbd/mangle_hash2.c
@@ -184,12 +184,12 @@ static const char *cache_lookup(u32 hash)
In this algorithm, mangled names use only pure ascii characters (no
multi-byte) so we can avoid doing a UCS2 conversion
-*/
-static BOOL is_mangled(const char *name)
+ */
+static BOOL is_mangled_component(const char *name)
{
int len, i;
- M_DEBUG(0,("is_mangled %s ?\n", name));
+ M_DEBUG(0,("is_mangled_component %s ?\n", name));
/* the best distinguishing characteristic is the ~ */
if (name[6] != '~') return False;
@@ -229,6 +229,39 @@ static BOOL is_mangled(const char *name)
}
+
+/*
+ determine if a string is possibly in a mangled format, ignoring
+ case
+
+ In this algorithm, mangled names use only pure ascii characters (no
+ multi-byte) so we can avoid doing a UCS2 conversion
+
+ NOTE! This interface must be able to handle a path with unix
+ directory separators. It should return true if any component is
+ mangled
+ */
+static BOOL is_mangled(const char *name)
+{
+ char *p;
+ char *s;
+
+ M_DEBUG(0,("is_mangled %s ?\n", name));
+
+ for (s=name; (p=strchr(s, '/')); s=p+1) {
+ char *component = strndup(s, PTR_DIFF(p, s));
+ if (is_mangled_component(component)) {
+ free(component);
+ return True;
+ }
+ free(component);
+ }
+
+ /* and the last part ... */
+ return is_mangled_component(s);
+}
+
+
/*
see if a filename is an allowable 8.3 name.
@@ -343,8 +376,12 @@ static BOOL check_cache(char *name)
}
/* we found it - construct the full name */
- strncpy(extension, name+9, 3);
- extension[3] = 0;
+ if (name[8] == '.') {
+ strncpy(extension, name+9, 3);
+ extension[3] = 0;
+ } else {
+ extension[0] = 0;
+ }
if (extension[0]) {
M_DEBUG(0,("check_cache: %s -> %s.%s\n", name, prefix, extension));