diff options
author | 2012-05-17 18:00:19 +0000 | |
---|---|---|
committer | 2012-05-17 18:00:19 +0000 | |
commit | aa89ff490e276575b788d97f54926cfe65bd9f2d (patch) | |
tree | d226b3f7e14c6bd15174c1053be83ea075954fb1 /usr.bin/less | |
parent | show the f_iflags; ok guenther (diff) | |
download | wireguard-openbsd-aa89ff490e276575b788d97f54926cfe65bd9f2d.tar.xz wireguard-openbsd-aa89ff490e276575b788d97f54926cfe65bd9f2d.zip |
Quit if write(2) returns -1 when writing to the tty, which can
happen if the tty is revoked. OK deraadt@
Diffstat (limited to 'usr.bin/less')
-rw-r--r-- | usr.bin/less/output.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/usr.bin/less/output.c b/usr.bin/less/output.c index 0f6417df001..a5908a10d38 100644 --- a/usr.bin/less/output.c +++ b/usr.bin/less/output.c @@ -98,6 +98,7 @@ flush() { register int n; register int fd; + ssize_t nwritten; n = ob - obuf; if (n == 0) @@ -305,8 +306,12 @@ flush() #endif #endif fd = (any_display) ? STDOUT_FILENO : STDERR_FILENO; - if (write(fd, obuf, n) != n) + nwritten = write(fd, obuf, n); + if (nwritten != n) { + if (nwritten == -1) + quit(QUIT_ERROR); screen_trashed = 1; + } ob = obuf; } |