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)
committerKarolin Seeger <kseeger@samba.org>
Wed, 24 Feb 2010 15:25:10 +0000 (16:25 +0100)
Fix use of uninitialized variable. This can lead to crashes if
mangling = hash processes names with no '.'.

Jeremy.
(cherry picked from commit df13b1303a751962d8f7d5298b39e4a7500fef15)
(cherry picked from commit e904ccd25a3b7050a8d1895c9535e42abd0b4d07)

source/smbd/mangle_hash.c

index e081a57484a8ac3083840d5870692a297be7c097..31e734de9dd99c615c19fe1420a28a61a936f7f8 100644 (file)
@@ -412,8 +412,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 )
@@ -452,7 +452,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 = '.';
+       }
 }
 
 /* ************************************************************************** **