diff --git a/usr.bin/tail/forward.c b/usr.bin/tail/forward.c index e57e8b5cac96..506aa7c0d399 100644 --- a/usr.bin/tail/forward.c +++ b/usr.bin/tail/forward.c @@ -1,4 +1,4 @@ -/* $NetBSD: forward.c,v 1.33 2015/10/09 17:51:26 christos Exp $ */ +/* $NetBSD: forward.c,v 1.34 2024/01/14 17:37:32 christos Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)forward.c 8.1 (Berkeley) 6/6/93"; #endif -__RCSID("$NetBSD: forward.c,v 1.33 2015/10/09 17:51:26 christos Exp $"); +__RCSID("$NetBSD: forward.c,v 1.34 2024/01/14 17:37:32 christos Exp $"); #endif /* not lint */ #include @@ -96,7 +96,7 @@ forward(FILE *fp, 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) { @@ -128,7 +128,7 @@ forward(FILE *fp, 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(); @@ -146,7 +146,7 @@ forward(FILE *fp, enum STYLE style, off_t off, struct stat *sbp) } break; case RLINES: - if (S_ISREG(sbp->st_mode)) { + if (S_ISREG(sbp->st_mode) && sbp->st_size > 0) { if (!off) { if (fseek(fp, 0L, SEEK_END) == -1) { ierr();