From fc42ff0212430274fd0001a492024510822a73a2 Mon Sep 17 00:00:00 2001 From: Nicolas Williams Date: Mon, 17 Jan 2022 11:16:07 -0600 Subject: [PATCH] krb5: Fix NULL-deref in send_to_kdc Coverity thinks `handle` in lib/krb5/send_to_kdc.c:krb5_sendto_context() at 1241 can be NULL, leading to a NULL derefence in `get_next()`. This is an attempt to fix this by having `get_next()` check handle for NULL. --- lib/krb5/krbhst.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/krb5/krbhst.c b/lib/krb5/krbhst.c index 9f0313f9a..925937a08 100644 --- a/lib/krb5/krbhst.c +++ b/lib/krb5/krbhst.c @@ -438,7 +438,7 @@ krb5_krbhst_get_addrinfo(krb5_context context, krb5_krbhst_info *host, static krb5_boolean get_next(struct krb5_krbhst_data *kd, krb5_krbhst_info **host) { - struct krb5_krbhst_info *hi = *kd->index; + struct krb5_krbhst_info *hi = kd ? *kd->index : NULL; if(hi != NULL) { *host = hi; kd->index = &(*kd->index)->next;