]> git.ipfire.org Git - thirdparty/lldpd.git/commitdiff
lib: correctly handle read failure
authorVincent Bernat <vincent@bernat.im>
Sun, 31 Aug 2014 05:31:57 +0000 (07:31 +0200)
committerVincent Bernat <vincent@bernat.im>
Sun, 31 Aug 2014 05:31:57 +0000 (07:31 +0200)
NEWS
src/lib/connection.c

diff --git a/NEWS b/NEWS
index 864ca2bbe448b5f26946cfcc861dba222d83824a..88633e60c8ae7cff3f7505b457f30ef9b245951b 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,6 +1,8 @@
 lldpd (0.7.11)
   * Features:
     + Ship bash and zsh completion.
+  * Fix:
+    + Handle correctly read failures in liblldpctl.
 
 lldpd (0.7.10)
   * Features:
index f7525704d801c18a8abe4ca3cb48c7087d728109..ee6e92ee63bbe93125176964e258447986a3f591 100644 (file)
@@ -67,7 +67,7 @@ sync_recv(lldpctl_conn_t *lldpctl,
     const uint8_t *data, size_t length, void *user_data)
 {
        struct lldpctl_conn_sync_t *conn = user_data;
-       size_t nb;
+       ssize_t nb;
        size_t remain, offset = 0;
 
        if (conn->fd == -1 &&
@@ -78,9 +78,11 @@ sync_recv(lldpctl_conn_t *lldpctl,
 
        remain = length;
        do {
-               if ((nb = read(conn->fd, (void*)data + offset, remain)) == -1 &&
-                   (errno == EAGAIN || errno == EINTR))
-                       continue;
+               if ((nb = read(conn->fd, (void*)data + offset, remain)) == -1) {
+                       if (errno == EAGAIN || errno == EINTR)
+                               continue;
+                       return LLDPCTL_ERR_CALLBACK_FAILURE;
+               }
                remain -= nb;
                offset += nb;
        } while (remain > 0 && nb > 0);