summaryrefslogtreecommitdiff
path: root/source3/libads
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2004-06-23 00:35:29 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 10:52:01 -0500
commit1f7dbded0435f4f6b3e141edb89025542b904a57 (patch)
treee1361485e70e41cc99520e195c7b0ec8d1d7fad0 /source3/libads
parent7825677b862bb62b8350b6fee458fbbecc53893f (diff)
downloadsamba-1f7dbded0435f4f6b3e141edb89025542b904a57.tar.gz
samba-1f7dbded0435f4f6b3e141edb89025542b904a57.tar.bz2
samba-1f7dbded0435f4f6b3e141edb89025542b904a57.zip
r1223: Fix valgrind error with realm manipulation.... Damn macros :-(.
Jeremy. (This used to be commit 5a1d8c3c9b8daa435f6eb5bc1652bab138e05dbf)
Diffstat (limited to 'source3/libads')
-rw-r--r--source3/libads/krb5_setpw.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/source3/libads/krb5_setpw.c b/source3/libads/krb5_setpw.c
index 111834e886..c7e9e3fe76 100644
--- a/source3/libads/krb5_setpw.c
+++ b/source3/libads/krb5_setpw.c
@@ -468,6 +468,7 @@ ADS_STATUS ads_krb5_set_password(const char *kdc_host, const char *princ,
char *princ_name = NULL;
char *realm = NULL;
krb5_creds creds, *credsp = NULL;
+ krb5_data orig_realm;
krb5_ccache ccache = NULL;
ZERO_STRUCT(creds);
@@ -518,12 +519,15 @@ ADS_STATUS ads_krb5_set_password(const char *kdc_host, const char *princ,
return ADS_ERROR_KRB5(ret);
}
- krb5_princ_set_realm(context, creds.server,
- krb5_princ_realm(context, principal));
+ /* The creds.server principal takes ownership of this memory.
+ Remember to set back to original value before freeing. */
+ orig_realm = *krb5_princ_realm(context, creds.server);
+ krb5_princ_set_realm(context, creds.server, krb5_princ_realm(context, principal));
ret = krb5_cc_get_principal(context, ccache, &creds.client);
if (ret) {
krb5_cc_close(context, ccache);
+ krb5_princ_set_realm(context, creds.server, &orig_realm);
krb5_free_principal(context, creds.server);
krb5_free_principal(context, principal);
krb5_free_context(context);
@@ -536,6 +540,7 @@ ADS_STATUS ads_krb5_set_password(const char *kdc_host, const char *princ,
if (ret) {
krb5_cc_close(context, ccache);
krb5_free_principal(context, creds.client);
+ krb5_princ_set_realm(context, creds.server, &orig_realm);
krb5_free_principal(context, creds.server);
krb5_free_principal(context, principal);
krb5_free_context(context);
@@ -551,6 +556,7 @@ ADS_STATUS ads_krb5_set_password(const char *kdc_host, const char *princ,
krb5_free_creds(context, credsp);
krb5_free_principal(context, creds.client);
+ krb5_princ_set_realm(context, creds.server, &orig_realm);
krb5_free_principal(context, creds.server);
krb5_free_principal(context, principal);
krb5_cc_close(context, ccache);