Skip to contentSkip to conversation

gssd: ensure that preferred_realm is non-NULL before passing it to strcmp

PATCH In review Jeff Layton 2 participants 2 messages Sep 8, 2014 – Sep 16, 2014

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 gssd: ensure that preferred_realm is non-NULL before passing it to strcmp

It's possible for "preferred_realm" to be NULL, in which case we don't want to pass it to strcmp. Other places that use this variable test whether it's NULL first -- we need to do the same here.

This should fix the gssd crash reported here:

    https://bugzilla.redhat.com/show_bug.cgi?id=1108615
---
 utils/gssd/krb5_util.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
utils/gssd/krb5_util.c +1 -1
index 8369fdf0ed27..f1ebc0d09731 100644
@@ -876,7 +876,7 @@ find_keytab_entry(krb5_context context, krb5_keytab kt, const char *tgtname,
 	i = 0;
 	realm = realmnames[i];
 
-	if (strcmp (realm, preferred_realm) != 0) {
+	if (preferred_realm && strcmp (realm, preferred_realm) != 0) {
 		realm = preferred_realm;
 		/* resetting the realmnames index */
 		i = -1;
Signature · 1 line
1.9.3
#1 lore raw
Quoted 10 lines · Jeff Layton

It's possible for "preferred_realm" to be NULL, in which case we don't want to pass it to strcmp. Other places that use this variable test whether it's NULL first -- we need to do the same here.

This should fix the gssd crash reported here:

    https://bugzilla.redhat.com/show_bug.cgi?id=1108615

Committed...

steved.

Quoted 18 lines
---
 utils/gssd/krb5_util.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
utils/gssd/krb5_util.c +1 -1
index 8369fdf0ed27..f1ebc0d09731 100644
@@ -876,7 +876,7 @@ find_keytab_entry(krb5_context context, krb5_keytab kt, const char *tgtname,
 	i = 0;
 	realm = realmnames[i];
 
-	if (strcmp (realm, preferred_realm) != 0) {
+	if (preferred_realm && strcmp (realm, preferred_realm) != 0) {
 		realm = preferred_realm;
 		/* resetting the realmnames index */
 		i = -1;