Sophie

Sophie

distrib > Mageia > 6 > armv7hl > media > core-updates-src > by-pkgid > a954455a16d4f7254951bfe34290f999 > files > 25

sssd-1.13.4-9.5.mga6.src.rpm

From 8b7e6b4aa15a177763d47819b26b01e94bfb40b8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Michal=20=C5=BDidek?= <mzidek@redhat.com>
Date: Tue, 12 Jul 2016 12:11:18 +0200
Subject: [PATCH 21/24] dyndns: Add checks for NULL
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Fixes:
https://fedorahosted.org/sssd/ticket/3076

We segfaulted in this area once. This patch
makes the code more defensive and adds
some DEBUG messages.

Normally the structures are filled in online
and/or resolve callbacks.

Reviewed-by: Pavel Březina <pbrezina@redhat.com>
(cherry picked from commit b5f61f8963300c9ba011436f234e9e10224aff6d)
(cherry picked from commit ae8c7c4010cb8fda478526771ef12d2bb8bfeffa)
---
 src/providers/ipa/ipa_dyndns.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/src/providers/ipa/ipa_dyndns.c b/src/providers/ipa/ipa_dyndns.c
index e7026eb275798f0ed21fb8490295b6e6d419d8ee..bd2612a1fedfd905c2a77a67d5951cb4eed8c5c6 100644
--- a/src/providers/ipa/ipa_dyndns.c
+++ b/src/providers/ipa/ipa_dyndns.c
@@ -163,6 +163,26 @@ ipa_dyndns_update_send(struct ipa_options *ctx)
     }
     state->ipa_ctx = ctx;
 
+    /* The following three checks are here to prevent SEGFAULT
+     * from ticket #3076. */
+    if (ctx->service == NULL) {
+        DEBUG(SSSDBG_CRIT_FAILURE, "service structure not initialized\n");
+        ret = EINVAL;
+        goto done;
+    }
+
+    if (ctx->service->sdap == NULL) {
+        DEBUG(SSSDBG_CRIT_FAILURE, "sdap structure not initialized\n");
+        ret = EINVAL;
+        goto done;
+    }
+
+    if (ctx->service->sdap->uri == NULL) {
+        DEBUG(SSSDBG_CRIT_FAILURE, "LDAP uri not set\n");
+        ret = EINVAL;
+        goto done;
+    }
+
     if (ctx->dyndns_ctx->last_refresh + 60 > time(NULL) ||
         ctx->dyndns_ctx->timer_in_progress) {
         DEBUG(SSSDBG_FUNC_DATA, "Last periodic update ran recently or timer "
-- 
2.7.4