aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2021-07-04 12:24:32 -0500
committerRob Landley <rob@landley.net>2021-07-04 12:24:32 -0500
commit98613d454671ebc3e1a761788453542cd93e6ada (patch)
treec903447a46a16b77b6fe9b398a302da23a47e4dc
parentba242e08ee83910596420f42830fd3d6fc1868d0 (diff)
downloadtoybox-98613d454671ebc3e1a761788453542cd93e6ada.tar.gz
Fix tail -F with no arguments.
fstat() doesn't fail on stdin, so check for fd 0 explicitly so we don't try to access zero length array when optc was zero. (Plus can't reopen '-'.)
-rw-r--r--toys/posix/tail.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/toys/posix/tail.c b/toys/posix/tail.c
index 98309c0f..0d13ab01 100644
--- a/toys/posix/tail.c
+++ b/toys/posix/tail.c
@@ -188,7 +188,9 @@ static void do_tail(int fd, char *name)
long bytes = TT.c, lines = TT.n;
int linepop = 1;
- if (fd == -1 && !FLAG(F)) return;
+ if (FLAG(F)) {
+ if (!fd) perror_exit("no -F with '-'");
+ } else if (fd == -1) return;
if (FLAG(f) || FLAG(F)) {
char *s = name;
struct stat sb;