diff options
author | Jim Meyering <jim@meyering.net> | 2001-11-13 10:14:12 +0000 |
---|---|---|
committer | Jim Meyering <jim@meyering.net> | 2001-11-13 10:14:12 +0000 |
commit | 5579ee544c18c78176474c1a0266ec25630e0980 (patch) | |
tree | e8f37aab88a9f68a8faf91c5bb45826b8f7f1017 | |
parent | 30690e6b57f71e65d0c21b24b39d62bf083fce5c (diff) | |
download | coreutils-5579ee544c18c78176474c1a0266ec25630e0980.tar.xz |
`tail /proc/ksyms' would segfault on Linux.
(tail_lines): Use status of lseek (...SEEK_END) call
in deciding whether to call file_lines or pipe_lines.
From Herbert Xu.
-rw-r--r-- | src/tail.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/tail.c b/src/tail.c index 4973ef64b..375e6316b 100644 --- a/src/tail.c +++ b/src/tail.c @@ -1095,14 +1095,14 @@ tail_lines (const char *pretty_filename, int fd, long int n_lines) { /* Use file_lines only if FD refers to a regular file with its file pointer positioned at beginning of file. */ - /* FIXME: adding the lseek conjunct is a kludge. + /* FIXME: this first lseek conjunct is a kludge. Once there's a reasonable test suite, fix the true culprit: file_lines. file_lines shouldn't presume that the input file pointer is initially positioned to beginning of file. */ if (S_ISREG (stats.st_mode) - && lseek (fd, (off_t) 0, SEEK_CUR) == (off_t) 0) + && lseek (fd, (off_t) 0, SEEK_CUR) == (off_t) 0 + && (length = lseek (fd, (off_t) 0, SEEK_END)) >= 0) { - length = lseek (fd, (off_t) 0, SEEK_END); if (length != 0 && file_lines (pretty_filename, fd, n_lines, length)) return 1; } |