[SSSD] [PATCH] RESOLV: Do not steal the resulting hostent on error

Jakub Hrozek jhrozek at redhat.com
Sun Dec 16 22:38:05 UTC 2012


I have not reproduced the access-after-free described in
https://fedorahosted.org/sssd/ticket/1706 but the backtrace matches the
fix and I think it's simply the correct thing to do.
-------------- next part --------------
>From d4f0270452697e805bd2077e91f4b1aa1636d0f2 Mon Sep 17 00:00:00 2001
From: Jakub Hrozek <jhrozek at redhat.com>
Date: Sun, 16 Dec 2012 23:31:09 +0100
Subject: [PATCH] RESOLV: Do not steal the resulting hostent on error

https://fedorahosted.org/sssd/ticket/1706
---
 src/resolv/async_resolv.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/resolv/async_resolv.c b/src/resolv/async_resolv.c
index 00aed1434d2cbaf3e43d8cf54742180ab1a3f9fd..268d266a43fec8bfb20ddb09aa75a893c8b9de9c 100644
--- a/src/resolv/async_resolv.c
+++ b/src/resolv/async_resolv.c
@@ -1080,12 +1080,13 @@ resolv_gethostbyname_dns_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
     if (timeouts) {
         *timeouts = state->timeouts;
     }
+
+    TEVENT_REQ_RETURN_ON_ERROR(req);
+
     if (rhostent) {
         *rhostent = talloc_steal(mem_ctx, state->rhostent);
     }
 
-    TEVENT_REQ_RETURN_ON_ERROR(req);
-
     return EOK;
 }
 
-- 
1.8.0.2



More information about the sssd-devel mailing list