summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2009-12-21 17:46:32 -0800
committerJeremy Allison <jra@samba.org>2009-12-21 17:46:32 -0800
commit100168dfec533a7afd8f2dd246f1b66b11ad7162 (patch)
treeec42599d69642d872229d4ee7d900ae0e09f2406
parentfd5350de1f6c233b275b463a35eac48f85478337 (diff)
downloadsamba-100168dfec533a7afd8f2dd246f1b66b11ad7162.tar.gz
samba-100168dfec533a7afd8f2dd246f1b66b11ad7162.tar.bz2
samba-100168dfec533a7afd8f2dd246f1b66b11ad7162.zip
Fix bug reported in mangle_hash code (no bugid yet).
Don't change the contents of a const string via a pointer alias (or if you do, change it back.....). Jeremy.
-rw-r--r--source3/smbd/mangle_hash.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/source3/smbd/mangle_hash.c b/source3/smbd/mangle_hash.c
index c08bc4019a..8369af418a 100644
--- a/source3/smbd/mangle_hash.c
+++ b/source3/smbd/mangle_hash.c
@@ -429,6 +429,13 @@ static void cache_mangled_name( const char mangled_name[13],
if( !s1[i] && !s2[i] ) {
/* Truncate at the '.' */
*s1 = '\0';
+ /*
+ * DANGER WILL ROBINSON - this
+ * is changing a const string via
+ * an aliased pointer ! Remember to
+ * put it back once we've used it.
+ * JRA
+ */
*s2 = '\0';
}
}
@@ -440,6 +447,8 @@ static void cache_mangled_name( const char mangled_name[13],
} else {
DEBUG(5,("cache_mangled_name: Stored entry %s -> %s\n", mangled_name_key, raw_name));
}
+ /* Restore the change we made to the const string. */
+ *s2 = '.';
}
/* ************************************************************************** **