1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-22 13:34:15 +03:00

lib:krb5_wrap: Add Heimdal‐specific smb_krb5_princ_component() implementation

This implementation doesn’t rely on a variable of static storage
duration being used as a conduit for the return value.

Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
This commit is contained in:
Joseph Sutton 2023-09-05 15:07:05 +12:00 committed by Andrew Bartlett
parent eec9e54592
commit 229d26e25e
2 changed files with 20 additions and 3 deletions

View File

@ -142,14 +142,30 @@ const krb5_data *krb5_princ_component(krb5_context context,
#endif
krb5_error_code smb_krb5_princ_component(krb5_context context,
krb5_principal principal,
krb5_const_principal principal,
int i,
krb5_data *data);
krb5_error_code smb_krb5_princ_component(krb5_context context,
krb5_principal principal,
krb5_const_principal principal,
int i,
krb5_data *data)
{
#if defined(HAVE_KRB5_PRINCIPAL_GET_COMP_STRING) && !defined(HAVE_KRB5_PRINC_COMPONENT)
const char *component = NULL;
if (i < 0) {
return EINVAL;
}
component = krb5_principal_get_comp_string(context, principal, i);
if (component == NULL) {
return ENOENT;
}
*data = smb_krb5_make_data(discard_const_p(char, component), strlen(component));
return 0;
#else
const krb5_data *kdata = NULL;
if (i < 0) {
@ -164,6 +180,7 @@ krb5_error_code smb_krb5_princ_component(krb5_context context,
*data = *kdata;
return 0;
#endif
}
/**********************************************************

View File

@ -66,7 +66,7 @@ const krb5_data *krb5_princ_component(krb5_context context, krb5_principal princ
#endif
krb5_error_code smb_krb5_princ_component(krb5_context context,
krb5_principal principal,
krb5_const_principal principal,
int i,
krb5_data *data);