diff options
author | Ricardo Mestre <mestre@cvs.openbsd.org> | 2017-08-22 16:32:38 +0000 |
---|---|---|
committer | Ricardo Mestre <mestre@cvs.openbsd.org> | 2017-08-22 16:32:38 +0000 |
commit | ddc0084efafd75507d272743db8ccfd91ba30b22 (patch) | |
tree | 4b01d56fcb10447cf959bac007161cd3effb1a18 /usr.bin/cu/cu.c | |
parent | 6ac6d381146147a186c6015a4141f92963db30e6 (diff) |
Call isatty(3) prior to ioctl(TIOCEXCL) to check if cu(1) was invoked on a
non-TTY and if that's the case then close the application. Otherwise without
this verification if it's really a non-TTY then cu(1) will be aborted by
pledge(2).
feedback and OK by deraadt@
Diffstat (limited to 'usr.bin/cu/cu.c')
-rw-r--r-- | usr.bin/cu/cu.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/usr.bin/cu/cu.c b/usr.bin/cu/cu.c index efa2f4f05d7..8d1935a11c2 100644 --- a/usr.bin/cu/cu.c +++ b/usr.bin/cu/cu.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cu.c,v 1.24 2015/10/16 07:01:53 deraadt Exp $ */ +/* $OpenBSD: cu.c,v 1.25 2017/08/22 16:32:37 mestre Exp $ */ /* * Copyright (c) 2012 Nicholas Marriott <nicm@openbsd.org> @@ -162,6 +162,8 @@ main(int argc, char **argv) line_fd = open(line_path, flags); if (line_fd < 0) err(1, "open(\"%s\")", line_path); + if (!isatty(line_fd)) + err(1, "%s", line_path); if (ioctl(line_fd, TIOCEXCL) != 0) err(1, "ioctl(TIOCEXCL)"); if (tcgetattr(line_fd, &line_tio) != 0) |