]> git.ipfire.org Git - thirdparty/krb5.git/commitdiff
Avoid closing fd -1 in libkrad
authorLukas Slebodnik <lslebodn@redhat.com>
Sat, 21 Jun 2014 14:43:12 +0000 (16:43 +0200)
committerGreg Hudson <ghudson@mit.edu>
Sat, 12 Jul 2014 17:35:46 +0000 (13:35 -0400)
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@mit.edu: clarified commit message, minor style change]

src/lib/krad/remote.c

index bea14299e35ed2f1ced274d3fc63cef184ec8d8a..795485f19d0189ccea2c10e911907346f87d48c9 100644 (file)
@@ -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;