]> git.ipfire.org Git - thirdparty/krb5.git/commitdiff
Fix spin loop reading from KDC TCP socket
authorViktor Dukhovni <viktor@twosigma.com>
Tue, 25 Jun 2013 16:27:42 +0000 (12:27 -0400)
committerGreg Hudson <ghudson@mit.edu>
Wed, 26 Jun 2013 05:54:03 +0000 (01:54 -0400)
In the k5_sendto code for reading from a TCP socket, detect
end-of-stream when reading the length.  Otherwise we can get stuck in
an infinite loop of poll() and read().

[ghudson@mit.edu: commit message]

ticket: 7508
target_version: 1.11.4
tags: pullup

src/lib/krb5/os/sendto_kdc.c

index 3e4ec7e9b492cc5d17c1c9250ab0072b46281ccc..3c31d9f55d6b1b96cf869152731240f6572bbb9a 100644 (file)
@@ -853,9 +853,9 @@ service_tcp_fd(krb5_context context, struct conn_state *conn,
             nread = SOCKET_READ(conn->fd,
                                 conn->x.in.bufsizebytes + conn->x.in.bufsizebytes_read,
                                 4 - conn->x.in.bufsizebytes_read);
-            if (nread < 0) {
+            if (nread <= 0) {
+                e = nread ? SOCKET_ERRNO : ECONNRESET;
                 TRACE_SENDTO_KDC_TCP_ERROR_RECV_LEN(context, &conn->addr, e);
-                e = SOCKET_ERRNO;
                 goto kill_conn;
             }
             conn->x.in.bufsizebytes_read += nread;