Fix bug 7005 - mangle method = hash truncates files with dot '. ' character
authorJeremy Allison <jra@samba.org>
Tue, 22 Dec 2009 05:16:15 +0000 (21:16 -0800)
committerKarolin Seeger <kseeger@samba.org>
Wed, 13 Jan 2010 13:01:05 +0000 (14:01 +0100)
Don't change the contents of a const string via a pointer
alias (or if you do, change it back.....).

Jeremy.
(cherry picked from commit e3be5ddae764fae7ff4a3ef502e8461d0535bdc5)

source/smbd/mangle_hash.c

index 5de69e21ab419fa60522240e22bea1ba8c42fa80..7073c3c64eb4129f3acdd5a22e7f3c4cc8a9e317 100644 (file)
@@ -432,6 +432,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';
                }
        }
@@ -443,6 +450,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 = '.';
 }
 
 /* ************************************************************************** **