summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2003-08-27 18:17:33 +0000
committerJeremy Allison <jra@samba.org>2003-08-27 18:17:33 +0000
commit8df07f37a280a15e16423006e3d2cc66f03cd787 (patch)
tree450ce11d56678a04a417bdc1950ce8c3d64c6ce8
parent8dc1a4f30066f7cc25ab6b775b24f32ba275d78e (diff)
downloadsamba-8df07f37a280a15e16423006e3d2cc66f03cd787.tar.gz
samba-8df07f37a280a15e16423006e3d2cc66f03cd787.tar.bz2
samba-8df07f37a280a15e16423006e3d2cc66f03cd787.zip
Remove completely unneeded malloc/free out of this codepath.
Jeremy. (This used to be commit fda254169778cc3fa9c226473b5a1f95c17c99a7)
-rw-r--r--source3/smbd/mangle_hash2.c23
1 files changed, 11 insertions, 12 deletions
diff --git a/source3/smbd/mangle_hash2.c b/source3/smbd/mangle_hash2.c
index cdce28e1bd..27d044f56d 100644
--- a/source3/smbd/mangle_hash2.c
+++ b/source3/smbd/mangle_hash2.c
@@ -201,22 +201,24 @@ 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_component(const char *name)
+static BOOL is_mangled_component(const char *name, size_t len)
{
- unsigned int len, i;
+ unsigned int i;
M_DEBUG(10,("is_mangled_component %s ?\n", name));
/* check the length */
- len = strlen(name);
- if (len > 12 || len < 8) return False;
+ if (len > 12 || len < 8)
+ return False;
/* the best distinguishing characteristic is the ~ */
- if (name[6] != '~') return False;
+ if (name[6] != '~')
+ return False;
/* check extension */
if (len > 8) {
- if (name[8] != '.') return False;
+ if (name[8] != '.')
+ return False;
for (i=9; name[i]; i++) {
if (! FLAG_CHECK(name[i], FLAG_ASCII)) {
return False;
@@ -241,7 +243,7 @@ static BOOL is_mangled_component(const char *name)
}
}
- M_DEBUG(10,("is_mangled %s -> yes\n", name));
+ M_DEBUG(10,("is_mangled_component %s (len %u) -> yes\n", name, (unsigned int)len));
return True;
}
@@ -267,16 +269,13 @@ static BOOL is_mangled(const char *name)
M_DEBUG(10,("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);
+ if (is_mangled_component(s, PTR_DIFF(p, s))) {
return True;
}
- free(component);
}
/* and the last part ... */
- return is_mangled_component(s);
+ return is_mangled_component(s,strlen(s));
}