From nobody Mon Aug 19 07:59:53 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 4WnQ493qDfz5SW9q; Mon, 19 Aug 2024 07:59:53 +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 "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4WnQ493FVnz49j0; Mon, 19 Aug 2024 07:59:53 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1724054393; 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=hOChzROT4a0Slhel6P8fSFb2YxbcugCbEy5hX7bxSrk=; b=NqXEZSRS1KTu3mbKR0A5HgWophy+LdEWVNkvEZ32kx5Mp0prvlNxXgL3Lo3NySDn9v3LYe YxEEqLpJ4g2KqjrY+gImqlWIifXP4rkGMKrufglQiFDKau+sG52of7Ys1cSp0FQT//rAGm V+agMebrICdhu32VmKH/9CeNYPg2Ebxf5KT3Ji9iAwc8VqMjxHfd2JT5jVvMst/d1VATMe dDaCey6KD4kojhgeWu1h7pBPGurga/q42UdTVwIbz3P/YyHapwefLN51BO8J0FlDj1/cU6 w1EZELJS9A8u6okqPbf2qukqkAtA/gNg+Hs+l+mWfBN7SAqjSBaEAuT4VWIG/A== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1724054393; a=rsa-sha256; cv=none; b=O1mLaciBIyYZErohI6vacEmSSS8AbOoVk8zqM5+0g0Zj6gzt2hQwc3mvEWOa5Db2bU6rsb cSFq1lnwiFezdCx1c0w44vryoWiibJxnhW18PxkEx8lZpkHMFAuJkn0NQrjCO14hT+X5T/ YEozoRz3HGLqAvt4JRElMQgu9837yU35BgTp7hLqH+ztVcbUdr/2xVp3xWps0HBV6ON3EK M9V4w842cRF1NGwb+LIgFQmAtBcPhJMJ5ZdBrlTNhOehIbxD/xFE1A3ln959wN00l5LPoL U/CmYTFkIKWQV4EDdlkS89Tty9XSASiOge25fLuw9fU9sz0ooOxiJqNYHu126A== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1724054393; 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=hOChzROT4a0Slhel6P8fSFb2YxbcugCbEy5hX7bxSrk=; b=KAY36yaUST8sgaaWjWrQ41McIniogDrgjUhI384x8GK7clNUembBVPk9a9JKFATn/XbChL FGkb2pfSX541IQUbDaTSaW5VYkFdIwsPMnQZUl/w9acuJzQ0KrOVMyLHGGQwE2Vtc9h7e8 BXtLWYHaOjO0C0lWG8l12tkyHH9hgNu2t4PmVfQeEP45EgIkoudXLqp2SAg6C0+XPQgk0X XYsX13ZHFj22JRzoCAQNsAiyxyxB31hxM+jXLdthZBI04zNQ6z/XeZEYTE/uJI0Ui9witL WVcAYi2Um5VuanE1t0FUIB5F9HszEvpYEuiMfUTAQiBO2GUMvFudcK/ks5N5Cw== 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 4WnQ492kT0z17f9; Mon, 19 Aug 2024 07:59:53 +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 47J7xrj4016358; Mon, 19 Aug 2024 07:59:53 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 47J7xrmg016355; Mon, 19 Aug 2024 07:59:53 GMT (envelope-from git) Date: Mon, 19 Aug 2024 07:59:53 GMT Message-Id: <202408190759.47J7xrmg016355@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: 308399a179a4 - main - tail -F: fix crash 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: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 308399a179a49b7b858c725de10177fdb0502fd2 Auto-Submitted: auto-generated The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=308399a179a49b7b858c725de10177fdb0502fd2 commit 308399a179a49b7b858c725de10177fdb0502fd2 Author: Andre Albsmeier AuthorDate: 2024-08-19 07:54:24 +0000 Commit: Konstantin Belousov CommitDate: 2024-08-19 07:54:24 +0000 tail -F: fix crash When show() detects an error and closes the file and follow() wants to close it again, a NULL dereference occurs. PR: 280910 MFC after: 1 week --- usr.bin/tail/forward.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/usr.bin/tail/forward.c b/usr.bin/tail/forward.c index a5303385a74f..6d9db94a827f 100644 --- a/usr.bin/tail/forward.c +++ b/usr.bin/tail/forward.c @@ -379,7 +379,8 @@ follow(file_info_t *files, enum STYLE style, off_t off) sb2.st_dev != file->st.st_dev || sb2.st_nlink == 0) { show(file); - fclose(file->fp); + if (file->fp != NULL) + fclose(file->fp); file->fp = ftmp; memcpy(&file->st, &sb2, sizeof(struct stat));