]> andersk Git - moira.git/blobdiff - update/sendrecv.c
Need to handle new subnet status in AskMCDInfo(), too.
[moira.git] / update / sendrecv.c
index 888941d976f658a34403d2b820166fbaed89b10b..f82dc90f48aa9d86e35d9ff9c61f2e66fbaed590 100644 (file)
@@ -42,12 +42,19 @@ int send_int(int conn, long data)
 int recv_int(int conn, long *data)
 {
   char buf[8];
+  int len;
 
-  if (read(conn, buf, 8) != 8)
+  len = read(conn, buf, 8);
+  if (len == -1)
     {
       fail(conn, errno, "reading integer");
       return errno;
     }
+  else if (len < 8)
+    {
+      fail(conn, 0, "remote connection closed while reading integer");
+      return EIO;
+    }
   getlong((buf + 4), *data);
   return 0;
 }
@@ -81,16 +88,29 @@ int recv_string(int conn, char **buf, size_t *len)
   char tmp[4];
   int size, more;
 
-  if (read(conn, tmp, 4) != 4)
+  size = read(conn, tmp, 4);
+  if (size == -1)
     {
       fail(conn, errno, "reading string");
       return errno;
     }
-  if (read(conn, tmp, 4) != 4)
+  else if (size < 4)
+    {
+      fail(conn, 0, "remote connection closed while reading string");
+      return EIO;
+    }
+
+  size = read(conn, tmp, 4);
+  if (size == -1)
     {
       fail(conn, errno, "reading string");
       return errno;
     }
+  else if (size < 4)
+    {
+      fail(conn, 0, "remote connection closed while reading string");
+      return EIO;
+    }
   getlong(tmp, *len);
 
   *buf = malloc(*len);
This page took 0.035383 seconds and 4 git commands to generate.