diff options
author | Günther Deschner <gd@samba.org> | 2014-05-15 09:44:23 +0200 |
---|---|---|
committer | Günther Deschner <gd@samba.org> | 2014-08-08 16:37:36 +0200 |
commit | 496bbd12b3dd388221334bc02a4cff21ef23b752 (patch) | |
tree | 05337e78ab1d21f1fb755bd5c7ec9fca05d8f6d8 /lib | |
parent | 391396154620ddc897bf918abde69c8aea5046c9 (diff) | |
download | samba-496bbd12b3dd388221334bc02a4cff21ef23b752.tar.gz |
lib/krb5_wrap: make sure smb_krb5_principal_get_realm returns a malloced string.
Guenther
Signed-off-by: Guenther Deschner <gd@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/krb5_wrap/krb5_samba.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/lib/krb5_wrap/krb5_samba.c b/lib/krb5_wrap/krb5_samba.c index a3743aef449..8e560d2df3f 100644 --- a/lib/krb5_wrap/krb5_samba.c +++ b/lib/krb5_wrap/krb5_samba.c @@ -2297,19 +2297,21 @@ krb5_error_code smb_krb5_make_pac_checksum(TALLOC_CTX *mem_ctx, * @param[in] principal The principal * @return pointer to the realm * + * Caller must free if the return value is not NULL. + * */ char *smb_krb5_principal_get_realm(krb5_context context, krb5_const_principal principal) { #ifdef HAVE_KRB5_PRINCIPAL_GET_REALM /* Heimdal */ - return discard_const_p(char, krb5_principal_get_realm(context, principal)); + return strdup(discard_const_p(char, krb5_principal_get_realm(context, principal))); #elif defined(krb5_princ_realm) /* MIT */ krb5_data *realm; realm = krb5_princ_realm(context, principal); - return discard_const_p(char, realm->data); + return strndup(realm->data, realm->length); #else - return NULL; +#error UNKNOWN_GET_PRINC_REALM_FUNCTIONS #endif } |