]> git.ipfire.org Git - thirdparty/krb5.git/commitdiff
Fix null dereference qualifying short hostnames 1045/head
authorGreg Hudson <ghudson@mit.edu>
Tue, 3 Mar 2020 17:27:02 +0000 (12:27 -0500)
committerGreg Hudson <ghudson@mit.edu>
Thu, 5 Mar 2020 18:30:21 +0000 (13:30 -0500)
Fix the dnsglue.c PRIMARY_DOMAIN macro not to call strdup() with a
null pointer if no DNS search path is configured.

ticket: 8881
tags: pullup
target_version: 1.18-next

src/lib/krb5/os/dnsglue.c

index e35ca9d76c634ac27038b603407d747f9eff0b79..0cd213fdd7f4dc8bbc354753a384bd8ee8454dcd 100644 (file)
@@ -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