X-Git-Url: https://git.wh0rd.org/?p=dump.git;a=blobdiff_plain;f=rmt%2Frmt.c;fp=rmt%2Frmt.c;h=863f12651c68bd103a1972fd52a2078a889ead97;hp=05874a3f6a52f2d2e01d833c3747deb8d0efc6e8;hb=67febcc5e8d252f6f13784dfc2b540bacd4dda77;hpb=f0ab1ab5331f9ed387ade32d96b24285b0cd5282 diff --git a/rmt/rmt.c b/rmt/rmt.c index 05874a3..863f126 100644 --- a/rmt/rmt.c +++ b/rmt/rmt.c @@ -37,7 +37,7 @@ #ifndef lint static const char rcsid[] = - "$Id: rmt.c,v 1.28 2003/11/22 16:52:16 stelian Exp $"; + "$Id: rmt.c,v 1.29 2010/06/11 11:19:18 stelian Exp $"; #endif /* not linux */ /* @@ -310,8 +310,10 @@ top: cp = record; #endif (void)sprintf(resp, "A%lld\n", (long long)rval); - (void)write(1, resp, strlen(resp)); - (void)write(1, cp, rval); + if (write(1, resp, strlen(resp)) != strlen(resp)) + goto ioerror; + if (write(1, cp, rval) != rval) + goto ioerror; block += n >> 10; goto top; @@ -475,13 +477,17 @@ top: mtget.mt_fileno = swaplong(mtget.mt_fileno); mtget.mt_blkno = swaplong(mtget.mt_blkno); (void)sprintf(resp, "A%lld\n", (long long)rval); - (void)write(1, resp, strlen(resp)); - (void)write(1, (char *)&mtget, sizeof (mtget)); + if (write(1, resp, strlen(resp)) != strlen(resp)) + goto ioerror; + if (write(1, (char *)&mtget, sizeof (mtget)) != sizeof(mtget)) + goto ioerror; } else { rval = sizeof (mtget); (void)sprintf(resp, "A%lld\n", (long long)rval); - (void)write(1, resp, strlen(resp)); - (void)write(1, (char *)&mtget, sizeof (mtget)); + if (write(1, resp, strlen(resp)) != strlen(resp)) + goto ioerror; + if (write(1, (char *)&mtget, sizeof (mtget)) != sizeof(mtget)) + goto ioerror; } goto top; } @@ -546,7 +552,8 @@ top: respond: DEBUG1("rmtd: A %lld\n", (long long)rval); (void)sprintf(resp, "A%lld\n", (long long)rval); - (void)write(1, resp, strlen(resp)); + if (write(1, resp, strlen(resp)) != strlen(resp)) + goto ioerror; goto top; ioerror: error(errno); @@ -593,7 +600,8 @@ error(int num) DEBUG2("rmtd: E %d (%s)\n", num, strerror(num)); (void)snprintf(resp, sizeof(resp), "E%d\n%s\n", num, strerror(num)); - (void)write(1, resp, strlen(resp)); + if (write(1, resp, strlen(resp)) != strlen(resp)) + DEBUG("rmtd: write error\n"); } static unsigned long