[Debian-med-packaging] Bug#872865: libtecla: gl_get_line() fails to detect EOF
Guido Berhoerster
guido+debian.org at berhoerster.name
Mon Aug 21 21:43:09 UTC 2017
Package: libtecla1
Version: 1.6.3-1
Severity: normal
File: libtecla
Tags: patch upstream
gl_get_line() in server mode will errenously fail to detect an EOF
condition when reading from a fd which is not a tty and return
GL_READ_BLOCKED indefinetly. The bug is in gl_read_unmasked() which
calls isatty() before checking the errno from the read() call and
thereby clobbering errno if the fd in fact does not refer to a tty.
I've tried to contact upstream but the email address in the docs and
on the homepage bounces. A patch fixing the issue is attached.
-- System Information:
Debian Release: 9.1
APT prefers stable
APT policy: (500, 'stable')
Architecture: amd64 (x86_64)
Kernel: Linux 4.4.0-89-generic (SMP w/4 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=locale: Cannot set LC_ALL to default locale: No such file or directory
UTF-8), LANGUAGE=en_US.UTF-8 (charmap=locale: Cannot set LC_ALL to default locale: No such file or directory
UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)
Versions of packages libtecla1 depends on:
ii libc6 2.24-11+deb9u1
libtecla1 recommends no packages.
libtecla1 suggests no packages.
-- debconf information excluded
-------------- next part --------------
--- libtecla.orig/getline.c 2013-09-12 07:04:00.000000000 +0000
+++ libtecla/getline.c 2017-08-21 14:40:39.248681309 +0000
@@ -3296,6 +3296,7 @@
static GlReadStatus gl_read_unmasked(GetLine *gl, int fd, char *c)
{
int nread; /* The return value of read() */
+ int saved_errno;
/*
* Unblock the signals that we are trapping, while waiting for I/O.
*/
@@ -3307,6 +3308,7 @@
do {
errno = 0;
nread = read(fd, c, 1);
+ saved_errno = errno;
} while(nread < 0 && errno==EINTR);
/*
* Block all of the signals that we are trapping.
@@ -3319,7 +3321,7 @@
case 1:
return GL_READ_OK;
case 0:
- return (isatty(fd) || errno != 0) ? GL_READ_BLOCKED : GL_READ_EOF;
+ return (isatty(fd) || saved_errno != 0) ? GL_READ_BLOCKED : GL_READ_EOF;
default:
return GL_READ_ERROR;
};
More information about the Debian-med-packaging
mailing list