Author: abartlet Date: 2007-08-09 06:26:19 +0000 (Thu, 09 Aug 2007) New Revision: 24282
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=24282 Log: Try to fix the occasional Samba4 crash in BASE-BENCH-READWRITE, as seen in particular on opi. This looked like a Heimdal problem, but I think it was simply that we didn't do a talloc_reference() to keep tabs on the memory we were using, and in between obtaining the pointer and using it, it was assigned to unrelated memory. Andrew Bartlett Modified: branches/SAMBA_4_0/source/auth/credentials/credentials_krb5.c branches/SAMBA_4_0/source/auth/gensec/gensec_gssapi.c Changeset: Modified: branches/SAMBA_4_0/source/auth/credentials/credentials_krb5.c =================================================================== --- branches/SAMBA_4_0/source/auth/credentials/credentials_krb5.c 2007-08-08 23:56:55 UTC (rev 24281) +++ branches/SAMBA_4_0/source/auth/credentials/credentials_krb5.c 2007-08-09 06:26:19 UTC (rev 24282) @@ -259,7 +259,8 @@ cli_credentials_set_machine_account(cred); } - if (cred->ccache_obtained >= cred->ccache_threshold) { + if (cred->ccache_obtained >= cred->ccache_threshold && + cred->ccache_obtained > CRED_UNINITIALISED) { *ccc = cred->ccache; return 0; } @@ -298,7 +299,7 @@ * any cached credentials are now invalid */ if (obtained >= cred->client_gss_creds_obtained) { if (cred->client_gss_creds_obtained > CRED_UNINITIALISED) { - talloc_free(cred->client_gss_creds); + talloc_unlink(cred, cred->client_gss_creds); cred->client_gss_creds = NULL; } cred->client_gss_creds_obtained = CRED_UNINITIALISED; @@ -319,7 +320,7 @@ * any cached credentials are now invalid */ if (obtained >= cred->ccache_obtained) { if (cred->ccache_obtained > CRED_UNINITIALISED) { - talloc_free(cred->ccache); + talloc_unlink(cred, cred->ccache); cred->ccache = NULL; } cred->ccache_obtained = CRED_UNINITIALISED; @@ -350,7 +351,8 @@ OM_uint32 maj_stat, min_stat; struct gssapi_creds_container *gcc; struct ccache_container *ccache; - if (cred->client_gss_creds_obtained >= cred->client_gss_creds_threshold) { + if (cred->client_gss_creds_obtained >= cred->client_gss_creds_threshold && + cred->client_gss_creds_obtained > CRED_UNINITIALISED) { *_gcc = cred->client_gss_creds; return 0; } Modified: branches/SAMBA_4_0/source/auth/gensec/gensec_gssapi.c =================================================================== --- branches/SAMBA_4_0/source/auth/gensec/gensec_gssapi.c 2007-08-08 23:56:55 UTC (rev 24281) +++ branches/SAMBA_4_0/source/auth/gensec/gensec_gssapi.c 2007-08-09 06:26:19 UTC (rev 24282) @@ -370,7 +370,10 @@ } gensec_gssapi_state->client_cred = gcc; - + if (!talloc_reference(gensec_gssapi_state, gcc)) { + return NT_STATUS_NO_MEMORY; + } + return NT_STATUS_OK; }