[SSSD] [PATCH] krb5: Check return value of sss_krb5_princ_realm

Pavel Reichl preichl at redhat.com
Tue Oct 14 12:14:32 UTC 2014


On 10/14/2014 01:59 PM, Lukas Slebodnik wrote:
> diff --git a/src/util/sss_krb5.c b/src/util/sss_krb5.c
> index b4012593d96bc951143e4bb2ba7a91d118b1a53c..7daedb47464917966350f94c7d5b0844ccee7edb 100644
> --- a/src/util/sss_krb5.c
> +++ b/src/util/sss_krb5.c
> @@ -834,8 +834,15 @@ void sss_krb5_get_init_creds_opt_set_canonicalize(krb5_get_init_creds_opt *opts,
>   void sss_krb5_princ_realm(krb5_context context, krb5_const_principal princ,
>                             const char **realm, int *len)
>   {
> -    *realm = krb5_principal_get_realm(context, princ);
> -    *len = strlen(*realm);
> +    const char *realm_str = krb5_principal_get_realm(context, princ);
> +
> +    if (realm_str != NULL) {
> +        *realm = krb5_principal_get_realm(context, princ);

Why do we have to call krb5_principal_get_realm() again here? Why can't 
we just reuse value in realm_str?

> +        *len = strlen(*realm);
> +    } else {
> +        *realm = NULL;
> +        *len = 0;
> +    }
>   }
Do we need realm_str at all? Can't we handle the check just with realm?
>   #else
>   void sss_krb5_princ_realm(krb5_context context, krb5_const_principal princ,
> -- 

Thanks for answering!



More information about the sssd-devel mailing list