summaryrefslogtreecommitdiffstats
path: root/src/util
diff options
context:
space:
mode:
authorLukas Slebodnik <lslebodn@redhat.com>2014-10-14 11:20:40 +0200
committerJakub Hrozek <jhrozek@redhat.com>2014-11-28 16:06:05 +0100
commit2dc519ba98ca886076ba9e16b95a72732909cea1 (patch)
tree59a4f8eab9a8ffcb800125d1df6de1c21f1aca89 /src/util
parentcd5033e86bb4065d75188e2b6ef287a4421344c8 (diff)
downloadsssd-2dc519ba98ca886076ba9e16b95a72732909cea1.tar.gz
sssd-2dc519ba98ca886076ba9e16b95a72732909cea1.tar.xz
sssd-2dc519ba98ca886076ba9e16b95a72732909cea1.zip
krb5: Check return value of krb5_principal_get_realm
Function krb5_principal_get_realm can return NULL an it would case segfault in function strlen. Reviewed-by: Pavel Reichl <preichl@redhat.com>
Diffstat (limited to 'src/util')
-rw-r--r--src/util/sss_krb5.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/util/sss_krb5.c b/src/util/sss_krb5.c
index 9eb34e17d..89240b86d 100644
--- a/src/util/sss_krb5.c
+++ b/src/util/sss_krb5.c
@@ -758,8 +758,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 = realm_str;
+ *len = strlen(realm_str);
+ } else {
+ *realm = NULL;
+ *len = 0;
+ }
}
#else
void sss_krb5_princ_realm(krb5_context context, krb5_const_principal princ,