From nobody Sun Dec 22 07:49:37 2024 X-Original-To: dev-commits-src-all@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 4YGCwd3Tt9z5jDCX; Sun, 22 Dec 2024 07:49:37 +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 "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4YGCwd2fSZz4h1P; Sun, 22 Dec 2024 07:49:37 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1734853777; 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=FnfpJq4qEpHvgQfOCb0h0kAPv4NC2HtHFRKvJgaf6Q8=; b=ZcQNZrX0nIkEl+jeEKfsv2uKWZcoa+f35RhhDiwj4w3Sag1YH9l90Svwjvthdx7KuHN4Md jpO07OUm6K31qUoy3IpUvzrOKsLv6oyNQGRIHJDnNWo+Q8CE9dtQRbW/mOGYQv8sRG4w8O nQYWNNk46UvPT2RsCZzEtO2lEFB4aXRbEXAx920wyibV8Kjy5Eyj18lb4yDKPssRrVMP0Y lxRCbwjwASQB7Tg1DhPRD5dJEgJi064rQ/WDlTkc91gU9z0XLwmTFE9hRteUz5dMbGezHX x74N5e7x3RHtj2UeUxTq74X/25CGn3o/Z+kGGorXWk8qms+m7C+RglHLnb9dfw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1734853777; 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=FnfpJq4qEpHvgQfOCb0h0kAPv4NC2HtHFRKvJgaf6Q8=; b=WxBoO4ospfsUXOKVbZPh0Bz0mEEOYiCnBdiUWpik/aqW+E9uuele7wUZonIcwxH87+Ukkd XyELYSw0Ak6nFJFlw4bIYMhLGJ8fdaPHViUOvQrybK0eaGjsgk57xF1f8ITzplsCZCURbb PWYcjlHPB5lsf5O6MCtzgpXOvIDmaPp0RxjDbNyaq6dWNWtO3UiFXp22UyPfenrNvzwSL2 zOXxnbX9zSWdinK8w1zyyszdg/oPm4rMVmrHjD43FPym4PDQ0ETLG5Rw2hyHeRGPQAmEx6 AktBUFUsKn2ndBf/pjSmZBy1+mFGpwSL6sLHcB2yCVKD1KkZr3khICvx0+B9yw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1734853777; a=rsa-sha256; cv=none; b=g5ncC/Mt39wC1sDcIhGHruAyJ3CaJyUbfgdCrVF7c/q9+hykmlFI56xYnk5Omtk2npBzBX UgskYbb1k+Jhf+5oAsBxZRkPF8JUNfuK9OFl8LaZxDAebMOJRIJicx/o5x+aC31THW4lpA 1lrHg+5LkwJmCa7NzBnqH8SYVq0THJSZiL8f8EPVhCl5hXV+NpZfBC2FlE8+bljCbrhM/Z xA1YQPcrg8AZs9JTWIEerm1ejUpZH08pPVSPE9NQ9xSPpckqC2AzjNy03kLN++/EYRf7X5 k+RwWFKUikK0+EkvkqqVoYkh3ZPtL3qfS8WaBrFJ56LWx/2r+qMU1nddhigSXA== 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 4YGCwd2GzFz10XG; Sun, 22 Dec 2024 07:49:37 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 4BM7nbMT023486; Sun, 22 Dec 2024 07:49:37 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 4BM7nbEV023483; Sun, 22 Dec 2024 07:49:37 GMT (envelope-from git) Date: Sun, 22 Dec 2024 07:49:37 GMT Message-Id: <202412220749.4BM7nbEV023483@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Xin LI Subject: git: 1c6b4a0f3eb0 - stable/14 - MFC: tail: Do not trust st_size if it equals zero. List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@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/stable/14 X-Git-Reftype: branch X-Git-Commit: 1c6b4a0f3eb089e2eba644b604af40d7dbaff47a Auto-Submitted: auto-generated The branch stable/14 has been updated by delphij: URL: https://cgit.FreeBSD.org/src/commit/?id=1c6b4a0f3eb089e2eba644b604af40d7dbaff47a commit 1c6b4a0f3eb089e2eba644b604af40d7dbaff47a Author: Ricardo Branco AuthorDate: 2024-01-03 20:32:47 +0000 Commit: Xin LI CommitDate: 2024-12-22 07:49:30 +0000 MFC: tail: Do not trust st_size if it equals zero. PR: bin/276107 (cherry picked from commit 1fb3caee72241b9b4dacbfb0109c972a86d4401f) --- 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 2edf8730e8b1..afbff43e6063 100644 --- a/usr.bin/tail/forward.c +++ b/usr.bin/tail/forward.c @@ -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);