[prev in list] [next in list] [prev in thread] [next in thread] 

List:       busybox-cvs
Subject:    [BusyBox-cvs] busybox/coreutils tee.c,1.26,1.27
From:       mjn3 () busybox ! net (Manuel Novoa III,,,)
Date:       2004-05-26 9:21:24
Message-ID: 20040526152121.E51EBB4020 () codepoet ! org
[Download RAW message or body]

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

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic