memort corruption from mlock() changes

Gerald (Jerry) Carter jerry at samba.org
Fri Feb 23 14:12:34 GMT 2007


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Guenther,

Please try this patch that converts the talloc()'d memory
to a malloc() before trying to mlock() it.  This clears
up the crash and hangs on my Ubuntu systems.  Should be fine
on my Solaris box as well but I've yet to test that.

If this works we could also convert to memalign as
James suggested but would need to add configure tests
I assume.  This is a simpler change for now.



cheers, jerry
=====================================================================
Samba                                    ------- http://www.samba.org
Centeris                         -----------  http://www.centeris.com
"What man is a man who does not make the world better?"      --Balian
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.4 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFF3vZRIR7qMdg1EfYRAqnzAJ4hVAsynMBDfJUojzjiEsIIMWzH6QCg0jZ3
H71vV9cS4BrDDGgk3XsM/6M=
=e211
-----END PGP SIGNATURE-----
-------------- next part --------------
Index: nsswitch/winbindd_cred_cache.c
===================================================================
--- nsswitch/winbindd_cred_cache.c	(revision 13466)
+++ nsswitch/winbindd_cred_cache.c	(working copy)
@@ -488,10 +488,11 @@
 
 	memcredp->len += psize;
 
-	memcredp->buffer = (unsigned char *)TALLOC_ZERO(memcredp, memcredp->len);
+	memcredp->buffer = (unsigned char *)SMB_XMALLOC_ARRAY(unsigned char*, memcredp->len);
 	if (!memcredp->buffer) {
 		return NT_STATUS_NO_MEMORY;
 	}
+	memset( memcredp->buffer, 0x0, memcredp->len );	
 
 	/* point the nt_hash at the page boundary in the buffer */
 	memcredp->nt_hash = memcredp->buffer + 
@@ -542,7 +543,7 @@
 		return map_nt_error_from_unix(errno);
 	}
 	memset(memcredp->nt_hash, '\0', memcredp->len);
-	TALLOC_FREE(memcredp->buffer);
+	SAFE_FREE(memcredp->buffer);
 	memcredp->nt_hash = NULL;
 	memcredp->lm_hash = NULL;
 	memcredp->pass = NULL;


More information about the samba-technical mailing list