summaryrefslogtreecommitdiffstats
path: root/daemon/proto.c
diff options
context:
space:
mode:
authorRichard Jones <rjones@redhat.com>2009-04-26 09:51:30 +0100
committerRichard Jones <rjones@redhat.com>2009-04-26 09:51:30 +0100
commit38f9222d21fb3c3005872de05247ff16a66db945 (patch)
tree3d09d3e969135f41a41f787d98938fda297bbea3 /daemon/proto.c
parente65e1d5d0053431702bc99e5d59725324adf1af5 (diff)
downloadlibguestfs-38f9222d21fb3c3005872de05247ff16a66db945.tar.gz
libguestfs-38f9222d21fb3c3005872de05247ff16a66db945.tar.xz
libguestfs-38f9222d21fb3c3005872de05247ff16a66db945.zip
Carefully check return values from xwrite.
Diffstat (limited to 'daemon/proto.c')
-rw-r--r--daemon/proto.c22
1 files changed, 18 insertions, 4 deletions
diff --git a/daemon/proto.c b/daemon/proto.c
index becf27c3..ffb4a4e8 100644
--- a/daemon/proto.c
+++ b/daemon/proto.c
@@ -79,6 +79,7 @@ main_loop (int _sock)
xread (sock, buf, len);
+#if 0
if (verbose) {
int i, j;
@@ -99,6 +100,7 @@ main_loop (int _sock)
printf ("|\n");
}
}
+#endif
/* Decode the message header. */
xdrmem_create (&xdr, buf, len, XDR_DECODE);
@@ -209,8 +211,14 @@ send_error (const char *msg)
xdr_uint32_t (&xdr, &len);
xdr_destroy (&xdr);
- (void) xwrite (sock, lenbuf, 4);
- (void) xwrite (sock, buf, len);
+ if (xwrite (sock, lenbuf, 4) == -1) {
+ fprintf (stderr, "xwrite failed\n");
+ exit (1);
+ }
+ if (xwrite (sock, buf, len) == -1) {
+ fprintf (stderr, "xwrite failed\n");
+ exit (1);
+ }
}
void
@@ -250,8 +258,14 @@ reply (xdrproc_t xdrp, char *ret)
xdr_uint32_t (&xdr, &len);
xdr_destroy (&xdr);
- (void) xwrite (sock, lenbuf, 4);
- (void) xwrite (sock, buf, len);
+ if (xwrite (sock, lenbuf, 4) == -1) {
+ fprintf (stderr, "xwrite failed\n");
+ exit (1);
+ }
+ if (xwrite (sock, buf, len) == len) {
+ fprintf (stderr, "xwrite failed\n");
+ exit (1);
+ }
}
/* Receive file chunks, repeatedly calling 'cb'. */