summaryrefslogtreecommitdiff
path: root/source3/smbd
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2000-04-23 07:40:13 +0000
committerAndrew Tridgell <tridge@samba.org>2000-04-23 07:40:13 +0000
commit71499fbe98b35b7253dbe158ba9d417adecefdc9 (patch)
tree992bb36f6cf4f834f5d235dc92842552bc92fec2 /source3/smbd
parent9e3f457db01aaa97d05b40b265d6659597a03392 (diff)
downloadsamba-71499fbe98b35b7253dbe158ba9d417adecefdc9.tar.gz
samba-71499fbe98b35b7253dbe158ba9d417adecefdc9.tar.bz2
samba-71499fbe98b35b7253dbe158ba9d417adecefdc9.zip
avoided a memory leak in the ubi code by deleting a mangled cache
entry before adding to ensure that we don't ever add a duplicate entry this code can be removed when ubi gets fixed (This used to be commit 062d79bf8ba5308803393c7b9140d1f77db3690f)
Diffstat (limited to 'source3/smbd')
-rw-r--r--source3/smbd/mangle.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/source3/smbd/mangle.c b/source3/smbd/mangle.c
index e47bcd896f..8ac91d49c8 100644
--- a/source3/smbd/mangle.c
+++ b/source3/smbd/mangle.c
@@ -465,7 +465,8 @@ static signed int cache_compare( ubi_btItemPtr ItemPtr, ubi_btNodePtr NodePtr )
*/
static void cache_free_entry( ubi_trNodePtr WarrenZevon )
{
- free( WarrenZevon );
+ ZERO_STRUCTP(WarrenZevon);
+ free( WarrenZevon );
} /* cache_free_entry */
/* ************************************************************************** **
@@ -575,6 +576,15 @@ static void cache_mangled_name( char *mangled_name, char *raw_name )
s2 = (char *)&(s1[mangled_len + 1]);
(void)StrnCpy( s1, mangled_name, mangled_len );
(void)StrnCpy( s2, raw_name, raw_len );
+
+ /* possibly delete an old entry - this avoids a memory leak in the
+ ubi code to do with overwriting existing entries.
+
+ remove this test when ubi gets fixed */
+ if (ubi_cacheGet(mangled_cache, s1)) {
+ ubi_cacheDelete(mangled_cache, s1);
+ }
+
ubi_cachePut( mangled_cache, i, new_entry, s1 );
} /* cache_mangled_name */