]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
script: Fix mangled EOF and hang on big endian
authorStanislav Brabec <sbrabec@suse.cz>
Thu, 14 May 2015 15:55:56 +0000 (17:55 +0200)
committerKarel Zak <kzak@redhat.com>
Fri, 15 May 2015 10:56:46 +0000 (12:56 +0200)
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

index 02ba5965db6b1d74a2cae82c60ce8ee09cbf30c9..e0083f246ed42f947cb8d7f33aa6031cd45d56b9 100644 (file)
@@ -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();
                }