diff options
author | Nick Kralevich <nnk@google.com> | 2018-10-22 10:18:14 -0500 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2018-10-22 10:18:14 -0500 |
commit | ad1f2685eb2768dbc2b52a9962d6279aa90a343d (patch) | |
tree | 4aa04d07fb311fedd81dae4725ea1adbe0c6c66e /lib | |
parent | e13985bf81681373fe4337d03382e3c0201912ba (diff) | |
download | toybox-ad1f2685eb2768dbc2b52a9962d6279aa90a343d.tar.gz |
Don't call TIOCGWINSZ on non-ttys
Prior to calling TIOCGWINSZ on stdin/stdout/stderr, check to see if the
file descriptor is a tty. Calling TIOCGWINSZ on a non-tty doesn't make
any sense.
Calling TIOCGWINSZ on a non-tty is mildly problematic for systems like
Android where strict ioctl filtering is in place, and generates SELinux
audit noise.
Strict ioctl filtering for non-filesystem fifo_files (eg pipe() or
pipe2() generated pipes) was enabled in Android in commit
https://android-review.googlesource.com/c/platform/system/sepolicy/+/792599
Diffstat (limited to 'lib')
-rw-r--r-- | lib/interestingtimes.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/interestingtimes.c b/lib/interestingtimes.c index 9cf84041..a1aa2b67 100644 --- a/lib/interestingtimes.c +++ b/lib/interestingtimes.c @@ -27,7 +27,7 @@ int terminal_size(unsigned *xx, unsigned *yy) // stdin, stdout, stderr for (i=0; i<3; i++) { memset(&ws, 0, sizeof(ws)); - if (!ioctl(i, TIOCGWINSZ, &ws)) { + if (isatty(i) && !ioctl(i, TIOCGWINSZ, &ws)) { if (ws.ws_col) x = ws.ws_col; if (ws.ws_row) y = ws.ws_row; |