mirror of
https://github.com/opnsense/src.git
synced 2026-05-28 04:12:45 -04:00
MFC: tail: Do not trust st_size if it equals zero.
PR: bin/276107 (cherry picked from commit 1fb3caee72241b9b4dacbfb0109c972a86d4401f)
This commit is contained in:
parent
538bf98c7c
commit
1c6b4a0f3e
1 changed files with 3 additions and 3 deletions
|
|
@ -105,7 +105,7 @@ forward(FILE *fp, const char *fn, enum STYLE style, off_t off, struct stat *sbp)
|
|||
case FBYTES:
|
||||
if (off == 0)
|
||||
break;
|
||||
if (S_ISREG(sbp->st_mode)) {
|
||||
if (S_ISREG(sbp->st_mode) && sbp->st_size > 0) {
|
||||
if (sbp->st_size < off)
|
||||
off = sbp->st_size;
|
||||
if (fseeko(fp, off, SEEK_SET) == -1) {
|
||||
|
|
@ -137,7 +137,7 @@ forward(FILE *fp, const char *fn, enum STYLE style, off_t off, struct stat *sbp)
|
|||
}
|
||||
break;
|
||||
case RBYTES:
|
||||
if (S_ISREG(sbp->st_mode)) {
|
||||
if (S_ISREG(sbp->st_mode) && sbp->st_size > 0) {
|
||||
if (sbp->st_size >= off &&
|
||||
fseeko(fp, -off, SEEK_END) == -1) {
|
||||
ierr(fn);
|
||||
|
|
@ -154,7 +154,7 @@ forward(FILE *fp, const char *fn, enum STYLE style, off_t off, struct stat *sbp)
|
|||
return;
|
||||
break;
|
||||
case RLINES:
|
||||
if (S_ISREG(sbp->st_mode))
|
||||
if (S_ISREG(sbp->st_mode) && sbp->st_size > 0)
|
||||
if (!off) {
|
||||
if (fseeko(fp, (off_t)0, SEEK_END) == -1) {
|
||||
ierr(fn);
|
||||
|
|
|
|||
Loading…
Reference in a new issue