Skip to contentSkip to conversation

script: Fix mangled EOF and hang on big endian

PATCH In review Stanislav Brabec 2 participants 2 messages May 14, 2015 – May 15, 2015 Util-Linux package

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 script: Fix mangled EOF and hang on big endian

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.

---
 term-utils/script.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
term-utils/script.c +2 -2
index 02ba596..e0083f2 100644
@@ -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();
 		}
Signature · 13 lines
2.3.7

-- 
Best Regards / S pozdravem,

Stanislav Brabec
software developer
---------------------------------------------------------------------
SUSE LINUX, s. r. o.                          e-mail: [email protected]
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
maintainer
#1 lore raw

term-utils/script.c doinput(void) { · line 380

Quoted 2 lines · Stanislav Brabec
term-utils/script.c +1 -1
-		int c = DEF_EOF;
+		char c = DEF_EOF;

Ah... so nice ;-) Applied, thanks.

Karel

Signature · 2 lines
 Karel Zak  <[email protected]>
 http://karelzak.blogspot.com