krb5 commit [krb5-1.18]: Fix null dereference qualifying short hostnames

Greg Hudson ghudson at mit.edu
Wed Mar 18 12:53:02 EDT 2020


https://github.com/krb5/krb5/commit/c57b3f7f36c417c72ac66b014e705bf457babd26
commit c57b3f7f36c417c72ac66b014e705bf457babd26
Author: Greg Hudson <ghudson at mit.edu>
Date:   Tue Mar 3 12:27:02 2020 -0500

    Fix null dereference qualifying short hostnames
    
    Fix the dnsglue.c PRIMARY_DOMAIN macro not to call strdup() with a
    null pointer if no DNS search path is configured.
    
    (cherry picked from commit cd82bf377e7fad2409c76bf8b241920692f34fda)
    
    ticket: 8881
    version_fixed: 1.18.1

 src/lib/krb5/os/dnsglue.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/lib/krb5/os/dnsglue.c b/src/lib/krb5/os/dnsglue.c
index e35ca9d..0cd213f 100644
--- a/src/lib/krb5/os/dnsglue.c
+++ b/src/lib/krb5/os/dnsglue.c
@@ -91,7 +91,7 @@ static int initparse(struct krb5int_dns_state *);
 #define DECLARE_HANDLE(h) struct __res_state h
 #define INIT_HANDLE(h) (memset(&h, 0, sizeof(h)), res_ninit(&h) == 0)
 #define SEARCH(h, n, c, t, a, l) res_nsearch(&h, n, c, t, a, l)
-#define PRIMARY_DOMAIN(h) strdup(h.dnsrch[0])
+#define PRIMARY_DOMAIN(h) ((h.dnsrch[0] == NULL) ? NULL : strdup(h.dnsrch[0]))
 #if HAVE_RES_NDESTROY
 #define DESTROY_HANDLE(h) res_ndestroy(&h)
 #else
@@ -104,7 +104,8 @@ static int initparse(struct krb5int_dns_state *);
 #define DECLARE_HANDLE(h)
 #define INIT_HANDLE(h) (res_init() == 0)
 #define SEARCH(h, n, c, t, a, l) res_search(n, c, t, a, l)
-#define PRIMARY_DOMAIN(h) strdup(_res.defdname)
+#define PRIMARY_DOMAIN(h) \
+    ((_res.defdname == NULL) ? NULL : strdup(_res.defdname))
 #define DESTROY_HANDLE(h)
 
 #endif


More information about the cvs-krb5 mailing list