gnu: emacs-consult: Fix grammar.
[jackhill/guix/guix.git] / gnu / packages / patches / mit-krb5-qualify-short-hostnames.patch
1 Fix a null pointer dereference when no DNS search path is configured.
2 This showed up as a segfault while running the gsasl test suite.
3
4 Taken from upstream:
5 https://github.com/krb5/krb5/commit/cd82bf377e7fad2409c76bf8b241920692f34fda
6
7 diff --git a/src/lib/krb5/os/dnsglue.c b/src/lib/krb5/os/dnsglue.c
8 index e35ca9d76c..0cd213fdd7 100644
9 --- a/src/lib/krb5/os/dnsglue.c
10 +++ b/src/lib/krb5/os/dnsglue.c
11 @@ -91,7 +91,7 @@ static int initparse(struct krb5int_dns_state *);
12 #define DECLARE_HANDLE(h) struct __res_state h
13 #define INIT_HANDLE(h) (memset(&h, 0, sizeof(h)), res_ninit(&h) == 0)
14 #define SEARCH(h, n, c, t, a, l) res_nsearch(&h, n, c, t, a, l)
15 -#define PRIMARY_DOMAIN(h) strdup(h.dnsrch[0])
16 +#define PRIMARY_DOMAIN(h) ((h.dnsrch[0] == NULL) ? NULL : strdup(h.dnsrch[0]))
17 #if HAVE_RES_NDESTROY
18 #define DESTROY_HANDLE(h) res_ndestroy(&h)
19 #else
20 @@ -104,7 +104,8 @@ static int initparse(struct krb5int_dns_state *);
21 #define DECLARE_HANDLE(h)
22 #define INIT_HANDLE(h) (res_init() == 0)
23 #define SEARCH(h, n, c, t, a, l) res_search(n, c, t, a, l)
24 -#define PRIMARY_DOMAIN(h) strdup(_res.defdname)
25 +#define PRIMARY_DOMAIN(h) \
26 + ((_res.defdname == NULL) ? NULL : strdup(_res.defdname))
27 #define DESTROY_HANDLE(h)
28
29 #endif