[PATCH] script: Fix mangled EOF and hang on big endian

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On s390 and other big endian machines, doinput() sends NUL instead of
EOF to the tty master. NUL does not even reach the slave, and it is
waiting for more data forever.

If STDIN is not a tty, the bug caused "^@" being into the log, and since
commit 032228c it also causes hang.

Signed-off-by: Stanislav Brabec <sbrabec@xxxxxxx>
---
 term-utils/script.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/term-utils/script.c b/term-utils/script.c
index 02ba596..e0083f2 100644
--- a/term-utils/script.c
+++ b/term-utils/script.c
@@ -377,9 +377,9 @@ doinput(void) {
 		 * We usually use this when stdin is not a tty, for example:
 		 * echo "ps" | script
 		 */
-		int c = DEF_EOF;
+		char c = DEF_EOF;
 
-		if (write_all(master, &c, 1)) {
+		if (write_all(master, &c, sizeof(char))) {
 			warn (_("write failed"));
 			fail();
 		}
-- 
2.3.7

-- 
Best Regards / S pozdravem,

Stanislav Brabec
software developer
---------------------------------------------------------------------
SUSE LINUX, s. r. o.                          e-mail: sbrabec@xxxxxxx
Lihovarská 1060/12                            tel: +49 911 7405384547
190 00 Praha 9                                 fax:  +420 284 084 001
Czech Republic                                    http://www.suse.cz/
PGP: 830B 40D5 9E05 35D8 5E27 6FA3 717C 209F A04F CD76
--
To unsubscribe from this list: send the line "unsubscribe util-linux" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux