From nobody Thu Jan 04 09:01:29 2024 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4T5LDT4gzCz567sP; Thu, 4 Jan 2024 09:01:29 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4T5LDT49cNz4lTx; Thu, 4 Jan 2024 09:01:29 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1704358889; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=MDN0/xNR0BTY2HG+2Mi0GRh+0WRLwUc+4Dvf78oY8rs=; b=l18Ip10Lm4qpcM4jmIxR85CxAg81hGWJ00JMDSvMaPJ40VheFGbqPeBMRmEmH4bkjsa+25 RDr5zCuz6eTcw2mXczR/iriPYei3pIRmwIgrpgz6mNJ9Du9nQLsxbqYrSCpxiItRjmrz7Y QtDWXBbs/6ikffRT4xqVdrpYK3RhT5nA6zMYawzQT+xgBSHH0ud0sY0iHRONi+hAU2CnTu aAOKNDTfpjQoJqzrrXjWTIFz3zTd51n/zy4mV4valAzb+Zlwrf2+affxxAv7cszBgf3xjB XLTtpK2ic2EGZ59PUaiuY31Kb8BvZJY/63krqvgHYjbhyJJY7wB4W6aPjMEQRg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1704358889; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=MDN0/xNR0BTY2HG+2Mi0GRh+0WRLwUc+4Dvf78oY8rs=; b=FqqqN5WabfRYLW4HrHB+b1Z9Mlpra949+CqaeT1QK76KyZGRoBlJOVwZGxQqfWMzeXS5eX vHyKDaADpI4XKEE2440yhwu2//nwLCD2pZNeAJ/kMMADx+GL8GwX4c2WoE7TpF1OSrlhmk wDKJHM5rfJDQph1iY7EfWITeN14N8p0dgdoTo1p7l4Bpf1l7sauX9UmBF2z6o2gRvqdtZR i4IkXSDCJvC8M9u2SZtNVIq4MehlwQvym+5tFVp3hngSp46t/V9qNWTSnyFGb/HxwUZ8Zq DS5bGZtR4OsArAki+A4hVvyAy3jRJXnnIYmWHYeXOktDt8y2nxQszCovWCHm9Q== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1704358889; a=rsa-sha256; cv=none; b=P0SmVOqNn4CpNbEt1ApoH5q+DS/bkau4SH4D+g110LhJdE+tXGYym/aW7F8y9u0sMEYvA9 Tni6KpaDQVvbUgC498nIEWIauf8ei786/DlLIaNV8LiadTR3iFTW8uxYr2sptXyvtzc+8P GcHgE937/CR7eBsYMLF2pFCyTHuHx2QEbH0Pa7aP3R7LF3Ofc/nZ0N3azkb5sAd4ugTeiq XkVwqoGYVZ517g4uAs2qGnJL3ZhUJmp3S7LRvQxRdzPPMzuvSdjNrffsIf7z3ViWHD7r+r 8dx2EiF+hJznIPJhMRKEfjm0WS+UirErH/PTatLQOAwnAy5bIlBI5LJ3GXj5+w== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4T5LDT3GRDz1MB7; Thu, 4 Jan 2024 09:01:29 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 40491Tap075859; Thu, 4 Jan 2024 09:01:29 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 40491TwK075844; Thu, 4 Jan 2024 09:01:29 GMT (envelope-from git) Date: Thu, 4 Jan 2024 09:01:29 GMT Message-Id: <202401040901.40491TwK075844@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Xin LI Subject: git: 1fb3caee7224 - main - tail: Do not trust st_size if it equals zero. List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: delphij X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 1fb3caee72241b9b4dacbfb0109c972a86d4401f Auto-Submitted: auto-generated The branch main has been updated by delphij: URL: https://cgit.FreeBSD.org/src/commit/?id=1fb3caee72241b9b4dacbfb0109c972a86d4401f commit 1fb3caee72241b9b4dacbfb0109c972a86d4401f Author: Ricardo Branco AuthorDate: 2024-01-03 20:32:47 +0000 Commit: Xin LI CommitDate: 2024-01-04 09:00:23 +0000 tail: Do not trust st_size if it equals zero. PR: bin/276107 MFC after: 1 week --- usr.bin/tail/forward.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/usr.bin/tail/forward.c b/usr.bin/tail/forward.c index 010a36b4c793..a5303385a74f 100644 --- a/usr.bin/tail/forward.c +++ b/usr.bin/tail/forward.c @@ -102,7 +102,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) { @@ -134,7 +134,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); @@ -151,7 +151,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);