[BusyBox-cvs] busybox/coreutils tee.c,1.26,1.27
Manuel Novoa III,,,
mjn3 at busybox.net
Wed May 26 15:21:21 UTC 2004
Update of /var/cvs/busybox/coreutils
In directory nail:/tmp/cvs-serv16264/coreutils
Modified Files:
tee.c
Log Message:
If read were to return with an error, bad things would happen. Fix it.
Also, make sure read errors are reflected in the applet exit code.
Index: tee.c
===================================================================
RCS file: /var/cvs/busybox/coreutils/tee.c,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -d -r1.26 -r1.27
--- a/tee.c 26 May 2004 10:26:10 -0000 1.26
+++ b/tee.c 26 May 2004 15:21:19 -0000 1.27
@@ -38,7 +38,7 @@
int flags;
int retval = EXIT_SUCCESS;
#ifdef CONFIG_FEATURE_TEE_USE_BLOCK_IO
- size_t c;
+ ssize_t c;
RESERVE_CONFIG_BUFFER(buf, BUFSIZ);
#else
int c;
@@ -78,12 +78,16 @@
*p = NULL; /* Store the sentinal value. */
#ifdef CONFIG_FEATURE_TEE_USE_BLOCK_IO
- while ((c = read(STDIN_FILENO, buf, BUFSIZ)) != 0) {
+ while ((c = safe_read(STDIN_FILENO, buf, BUFSIZ)) > 0) {
for (p=files ; *p ; p++) {
fwrite(buf, 1, c, *p);
}
}
+ if (c < 0) { /* Make sure read errors are signaled. */
+ retval = EXIT_FAILURE;
+ }
+
#ifdef CONFIG_FEATURE_CLEAN_UP
RELEASE_CONFIG_BUFFER(buf);
#endif
More information about the busybox-cvs
mailing list