krb5 commit: Avoid closing fd -1 in libkrad

Greg Hudson ghudson at MIT.EDU
Sat Jul 12 15:19:26 EDT 2014


https://github.com/krb5/krb5/commit/315d1ef769d3e3e7cc17884623c1baaad680c26b
commit 315d1ef769d3e3e7cc17884623c1baaad680c26b
Author: Lukas Slebodnik <lslebodn at redhat.com>
Date:   Sat Jun 21 16:43:12 2014 +0200

    Avoid closing fd -1 in libkrad
    
    If a krad_remote is released before its fd is set, we could close the
    file descriptor -1, which is harmless but incorrect.  Check the fd in
    remote_disconnect to avoid this.
    
    [ghudson at mit.edu: clarified commit message, minor style change]

 src/lib/krad/remote.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/src/lib/krad/remote.c b/src/lib/krad/remote.c
index bea1429..795485f 100644
--- a/src/lib/krad/remote.c
+++ b/src/lib/krad/remote.c
@@ -144,7 +144,8 @@ request_start_timer(request *r, verto_ctx *vctx)
 static void
 remote_disconnect(krad_remote *rr)
 {
-    close(rr->fd);
+    if (rr->fd >= 0)
+        close(rr->fd);
     verto_del(rr->io);
     rr->fd = -1;
     rr->io = NULL;


More information about the cvs-krb5 mailing list