CVS commit: src/usr.bin/tail

2024-01-14 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Jan 14 17:37:32 UTC 2024

Modified Files:
src/usr.bin/tail: forward.c

Log Message:
PR/57850: Ricardo Branco: tail does not work in some pseudo-filesystems
>From FreeBSD: https://github.com/NetBSD/src/pull/20


To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.34 src/usr.bin/tail/forward.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/tail/forward.c
diff -u src/usr.bin/tail/forward.c:1.33 src/usr.bin/tail/forward.c:1.34
--- src/usr.bin/tail/forward.c:1.33	Fri Oct  9 13:51:26 2015
+++ src/usr.bin/tail/forward.c	Sun Jan 14 12:37:32 2024
@@ -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_
 	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_
 		}
 		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_
 		}
 		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();



CVS commit: src/usr.bin/tail

2024-01-14 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Jan 14 17:37:32 UTC 2024

Modified Files:
src/usr.bin/tail: forward.c

Log Message:
PR/57850: Ricardo Branco: tail does not work in some pseudo-filesystems
>From FreeBSD: https://github.com/NetBSD/src/pull/20


To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.34 src/usr.bin/tail/forward.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/usr.bin/tail

2023-08-07 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Mon Aug  7 19:11:25 UTC 2023

Modified Files:
src/usr.bin/tail: tail.c

Log Message:
tail: adjust misleading indentation in macro. NFC.


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/usr.bin/tail/tail.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.bin/tail/tail.c
diff -u src/usr.bin/tail/tail.c:1.20 src/usr.bin/tail/tail.c:1.21
--- src/usr.bin/tail/tail.c:1.20	Tue Mar  6 03:33:26 2018
+++ src/usr.bin/tail/tail.c	Mon Aug  7 19:11:25 2023
@@ -40,7 +40,7 @@ __COPYRIGHT("@(#) Copyright (c) 1991, 19
 #if 0
 static char sccsid[] = "@(#)tail.c	8.1 (Berkeley) 6/6/93";
 #endif
-__RCSID("$NetBSD: tail.c,v 1.20 2018/03/06 03:33:26 eadler Exp $");
+__RCSID("$NetBSD: tail.c,v 1.21 2023/08/07 19:11:25 tnn Exp $");
 #endif /* not lint */
 
 #include 
@@ -94,7 +94,7 @@ main(int argc, char *argv[])
 	case '+':			\
 		if (off)		\
 			off -= (units);	\
-			style = (forward);\
+		style = (forward);	\
 		break;			\
 	case '-':			\
 		off = -off;		\



CVS commit: src/usr.bin/tail

2023-08-07 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Mon Aug  7 19:11:25 UTC 2023

Modified Files:
src/usr.bin/tail: tail.c

Log Message:
tail: adjust misleading indentation in macro. NFC.


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/usr.bin/tail/tail.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



Re: CVS commit: src/usr.bin/tail

2015-10-09 Thread Joerg Sonnenberger
On Fri, Oct 09, 2015 at 01:51:27PM -0400, Christos Zoulas wrote:
> Module Name:  src
> Committed By: christos
> Date: Fri Oct  9 17:51:27 UTC 2015
> 
> Modified Files:
>   src/usr.bin/tail: forward.c
> 
> Log Message:
> PR/50322: Timo Buhrmester: tail -F  misbehaves with stdin closed
> Compare fp with stdin not fileno(fp) with STDIN_FILENO, because if tail
> is called with 0 closed, then we are not going to be setting event filters
> for the file because we'll erroneously think it is stdin.

Well, you are not supposed to do that. We are just only enforcing it for
suid/sgid binaries.

Joerg