Fix bug #7154 - mangling method = hash can crash storing a name not containing a '.'
authorJeremy Allison <jra@samba.org>
Thu, 18 Feb 2010 19:22:44 +0000 (11:22 -0800)
committerJeremy Allison <jra@samba.org>
Thu, 18 Feb 2010 19:22:44 +0000 (11:22 -0800)
Fix use of uninitialized variable. This can lead to crashes if
mangling = hash processes names with no '.'.

Jeremy.

source3/smbd/mangle_hash.c

index 8369af418ae0d3242b4c129c220a564512d69acb..1482d10b7a240388b8c1d739cda0d76c36cf1c07 100644 (file)
@@ -408,8 +408,8 @@ static void cache_mangled_name( const char mangled_name[13],
 {
        TDB_DATA data_val;
        char mangled_name_key[13];
-       char *s1;
-       char *s2;
+       char *s1 = NULL;
+       char *s2 = NULL;
 
        /* If the cache isn't initialized, give up. */
        if( !tdb_mangled_cache )
@@ -448,7 +448,9 @@ static void cache_mangled_name( const char mangled_name[13],
                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 = '.';
+       if (s2) {
+               *s2 = '.';
+       }
 }
 
 /* ************************************************************************** **