summaryrefslogtreecommitdiff
path: root/lib/krb5_wrap
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2018-11-20 17:45:11 +0100
committerJeremy Allison <jra@samba.org>2018-11-28 17:44:15 +0100
commita167014554c9cac1ed751adce488dce164da5979 (patch)
treebb0efe6935fbd9f3849e273e1910085665148220 /lib/krb5_wrap
parentc39526eb7d19e97f001690834e8f3bfa03f4d20e (diff)
downloadsamba-a167014554c9cac1ed751adce488dce164da5979.tar.gz
krb5_wrap: Add a talloc_ctx to smb_krb5_principal_get_realm()
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
Diffstat (limited to 'lib/krb5_wrap')
-rw-r--r--lib/krb5_wrap/krb5_samba.c19
-rw-r--r--lib/krb5_wrap/krb5_samba.h3
2 files changed, 12 insertions, 10 deletions
diff --git a/lib/krb5_wrap/krb5_samba.c b/lib/krb5_wrap/krb5_samba.c
index a6ff97640ca..e8abfac1d8d 100644
--- a/lib/krb5_wrap/krb5_samba.c
+++ b/lib/krb5_wrap/krb5_samba.c
@@ -2780,24 +2780,25 @@ krb5_error_code smb_krb5_make_pac_checksum(TALLOC_CTX *mem_ctx,
/**
* @brief Get realm of a principal
*
+ * @param[in] mem_ctx The talloc ctx to put the result on
+ *
* @param[in] context The library context
*
* @param[in] principal The principal to get the realm from.
*
- * @return An allocated string with the realm or NULL if an error occurred.
- *
- * The caller must free the realm string with free() if not needed anymore.
+ * @return A talloced string with the realm or NULL if an error occurred.
*/
-char *smb_krb5_principal_get_realm(krb5_context context,
+char *smb_krb5_principal_get_realm(TALLOC_CTX *mem_ctx,
+ krb5_context context,
krb5_const_principal principal)
{
#ifdef HAVE_KRB5_PRINCIPAL_GET_REALM /* Heimdal */
- return strdup(discard_const_p(char, krb5_principal_get_realm(context, principal)));
+ return talloc_strdup(mem_ctx,
+ krb5_principal_get_realm(context, principal));
#elif defined(krb5_princ_realm) /* MIT */
- krb5_data *realm;
- realm = discard_const_p(krb5_data,
- krb5_princ_realm(context, principal));
- return strndup(realm->data, realm->length);
+ const krb5_data *realm;
+ realm = krb5_princ_realm(context, principal);
+ return talloc_strndup(mem_ctx, realm->data, realm->length);
#else
#error UNKNOWN_GET_PRINC_REALM_FUNCTIONS
#endif
diff --git a/lib/krb5_wrap/krb5_samba.h b/lib/krb5_wrap/krb5_samba.h
index fb3cb5f2ad8..4d0148fd047 100644
--- a/lib/krb5_wrap/krb5_samba.h
+++ b/lib/krb5_wrap/krb5_samba.h
@@ -298,7 +298,8 @@ krb5_error_code smb_krb5_make_pac_checksum(TALLOC_CTX *mem_ctx,
uint32_t *sig_type,
DATA_BLOB *sig_blob);
-char *smb_krb5_principal_get_realm(krb5_context context,
+char *smb_krb5_principal_get_realm(TALLOC_CTX *mem_ctx,
+ krb5_context context,
krb5_const_principal principal);
void smb_krb5_principal_set_type(krb5_context context,