All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] script: Fix mangled EOF and hang on big endian
@ 2015-05-14 15:55 Stanislav Brabec
  2015-05-15 10:58 ` Karel Zak
  0 siblings, 1 reply; 2+ messages in thread
From: Stanislav Brabec @ 2015-05-14 15:55 UTC (permalink / raw)
  To: util-linux

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@suse.cz>
---
 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@suse.cz
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

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] script: Fix mangled EOF and hang on big endian
  2015-05-14 15:55 [PATCH] script: Fix mangled EOF and hang on big endian Stanislav Brabec
@ 2015-05-15 10:58 ` Karel Zak
  0 siblings, 0 replies; 2+ messages in thread
From: Karel Zak @ 2015-05-15 10:58 UTC (permalink / raw)
  To: Stanislav Brabec; +Cc: util-linux

On Thu, May 14, 2015 at 05:55:56PM +0200, Stanislav Brabec wrote:
> -		int c = DEF_EOF;
> +		char c = DEF_EOF;

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

    Karel
-- 
 Karel Zak  <kzak@redhat.com>
 http://karelzak.blogspot.com

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-05-15 10:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-14 15:55 [PATCH] script: Fix mangled EOF and hang on big endian Stanislav Brabec
2015-05-15 10:58 ` Karel Zak

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.