krb5/0009-Fix-null-dereference-qualifying-short-hostnames.patch
Tomáš Chvátal f2bf4325ae Accepting request 789691 from home:scabrero:branches:network
- Fix segfault in k5_primary_domain; (bsc#1167620);
- Added patches:
  * 0009-Fix-null-dereference-qualifying-short-hostnames.patch

OBS-URL: https://build.opensuse.org/request/show/789691
OBS-URL: https://build.opensuse.org/package/show/network/krb5?expand=0&rev=228
2020-03-30 10:04:03 +00:00

44 lines
1.5 KiB
Diff

From 96d0ee0760a1c7cf735d04fbddf095a4c01ef190 Mon Sep 17 00:00:00 2001
From: Greg Hudson <ghudson@mit.edu>
Date: Tue, 3 Mar 2020 12:27:02 -0500
Subject: [PATCH] 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.
ticket: 8881
tags: pullup
target_version: 1.18-next
(cherry picked from commit cd82bf377e7fad2409c76bf8b241920692f34fda)
---
src/lib/krb5/os/dnsglue.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/src/lib/krb5/os/dnsglue.c b/src/lib/krb5/os/dnsglue.c
index e35ca9d76..0cd213fdd 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
--
2.25.1