summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThadeu Lima de Souza Cascardo <cascardo@cascardo.info>2014-03-15 14:17:56 -0300
committerThadeu Lima de Souza Cascardo <cascardo@cascardo.info>2014-03-15 14:17:56 -0300
commit8aa37bde56500659e9e7d646e9b08f3a13a5eac0 (patch)
tree0cb17bfbf6689a0e9f9534edd6656c415b4d0ecf
parentca7ec4885b8c4cd449da1d6e4c5dc1f6c38361e1 (diff)
Check return code for write when sending messages to server.
This not only avoids a warning, but prevents us from moving forward, when we should report an error, when write fails.
-rw-r--r--rnetclient.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/rnetclient.c b/rnetclient.c
index d264c72..04869fd 100644
--- a/rnetclient.c
+++ b/rnetclient.c
@@ -161,8 +161,12 @@ static int handshake(int c)
char buffer[16];
int r;
buffer[0] = 1;
- write(c, buffer, 1);
- write(c, "00000000000000", 14);
+ r = write(c, buffer, 1);
+ if (r < 1)
+ return -1;
+ r = write(c, "00000000000000", 14);
+ if (r < 14)
+ return -1;
r = read(c, buffer, 1);
if (r != 1 && buffer[0] != 'E')
return -1;