From 810fb7625b00298ec6c36e9aa291d2fda54bf506 Mon Sep 17 00:00:00 2001
From: dimitri staessens <dimitri.staessens@intec.ugent.be>
Date: Sun, 15 May 2016 11:51:52 +0200
Subject: ipcpd: shim-udp: added missing checks

---
 src/ipcpd/shim-udp/main.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

(limited to 'src')

diff --git a/src/ipcpd/shim-udp/main.c b/src/ipcpd/shim-udp/main.c
index 2d1691aa..9c295e30 100644
--- a/src/ipcpd/shim-udp/main.c
+++ b/src/ipcpd/shim-udp/main.c
@@ -196,10 +196,8 @@ static int port_id_to_fd(int port_id)
 
         for (i = 0; i < AP_MAX_FLOWS; ++i) {
                 if (_ap_instance->flows[i].port_id == port_id
-                    && _ap_instance->flows[i].state != FLOW_NULL) {
-
+                    && _ap_instance->flows[i].state != FLOW_NULL)
                         return i;
-                }
         }
 
         return -1;
@@ -457,15 +455,17 @@ static void * ipcp_udp_sdu_reader()
                                 continue;
 
                         n = sizeof r_saddr;
-                        n = recvfrom(fd,
-                                     buf,
-                                     SHIM_UDP_MAX_SDU_SIZE,
-                                     0,
-                                     (struct sockaddr *) &r_saddr,
-                                     (unsigned *) &n);
+                        if ((n = recvfrom(fd,
+                                          buf,
+                                          SHIM_UDP_MAX_SDU_SIZE,
+                                          0,
+                                          (struct sockaddr *) &r_saddr,
+                                          (unsigned *) &n)) <= 0)
+                                continue;
 
                         /* send the sdu to the correct port_id */
-                        ipcp_udp_flow_write(fd, buf, n);
+                        if (ipcp_udp_flow_write(fd, buf, n) < 0)
+                                LOG_ERR("Failed to write SDU.");
                 }
         }
 
-- 
cgit v1.2.3