From nobody Thu Feb 5 11:17:12 2026 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 4f6F715Njvz6FTln for ; Thu, 05 Feb 2026 11:17:17 +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 "R13" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4f6F714sVHz3lw6 for ; Thu, 05 Feb 2026 11:17:17 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1770290237; 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=Q/bzHECbZvtFmVDZATTz/kNBo14RZofV2BOgKiaIPa4=; b=l366dEDG3K+yQZ5UZgRPLENCFyCa08EoXaC9+Y9HClZsOsDuTnj0eFndUIl10y/3HS4M5S Iol1j6uLbO+kaalrgkJa2hKyk8pdTFJ+6lwpfBSTZ4V+mgjMdMOZJ5U1T9LfytTyxUeZxF ++owFR3810uUcB8vBklMkBf9Idx4nuoJhOWQElsaPniA6MozjrbO8x1fL+85fx7Lt8LJ/9 hXMfaJNE01ZRwALNWxaW8R/r1U73EhFMiDLRM8tMOHmhYyhHIpnnM5FXJa+cVfkfltlQt5 lzAGLmbHVx5LatrqCXWrwMCXGLhur2VImCe8/fq80NJOkdevGoETlohGRCyuUQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1770290237; a=rsa-sha256; cv=none; b=rSxQM2uUsXLvsOQBEKaWUDNwqOnKJ1wwDd8Eq6eaK30ZERmFxhhzD6QORtxzEH4J7D3dqS fLWgUYJoERJhNCDWUq5nkS+i+SNfJ6fir1hdHdLiAKpK5NHddgi/+o37JO2ALH+gD8ztrX YlALn7xUkeegpu8nOqGMpythkwYGNLIRbbtSX4wrDD5VkAAlQqGTcLXmZCJpotHKY+ZEXQ q2hDb6d05vH1mWuvj/JVJAZabjE3QZfMoooDOeUtOXMYiBWmRyU/uVGMCCh7WLoRUL+CbL Pp39hlk1JX4QVYlObIARUCyldxHOhwaMSnbMcyHZRupQwXtTkXAFrFA2wTPDzA== 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=1770290237; 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=Q/bzHECbZvtFmVDZATTz/kNBo14RZofV2BOgKiaIPa4=; b=s7a395fRo1hTn7+r6O0nK5H6LB55fH8NnTvDmBgG/t+b57VweYgxViVY7KtOqfaiFNPNic qlna3OG5ePA1YraztiFCsKX75a/ALRO80V6oMQO32rcH6ceSaiiKAZvM0gqTt4iVgvz30v PuZzYoGLjx9fqJqufMITNltY00icANAVNI4RFhui1C7wPSuwtQgcNzkmEOVOeylozNK54J DkmcQFsWHAC53CjMFjwpRbyB+VDqfcT7umrkukHm9+Zxxh5/INbd9VAb0dy5wmATKHHorO jQXxeaT/gDBi2uXG3bYbZEUf75cTdpXgB07ZeFQmhXFX3Psgg1+JOxHix8aqcg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4f6F713QRjzBjt for ; Thu, 05 Feb 2026 11:17:17 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 1d369 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Thu, 05 Feb 2026 11:17:12 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Aymeric Wibo Subject: git: b8d55a86995b - main - touch: Fix setting time of created file if fstat() fails 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: obiwac X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: b8d55a86995b5a8db5d1651c8dc9fc5093b67d2c Auto-Submitted: auto-generated Date: Thu, 05 Feb 2026 11:17:12 +0000 Message-Id: <69847c38.1d369.7d71508d@gitrepo.freebsd.org> The branch main has been updated by obiwac: URL: https://cgit.FreeBSD.org/src/commit/?id=b8d55a86995b5a8db5d1651c8dc9fc5093b67d2c commit b8d55a86995b5a8db5d1651c8dc9fc5093b67d2c Author: Aymeric Wibo AuthorDate: 2026-02-04 20:58:13 +0000 Commit: Aymeric Wibo CommitDate: 2026-02-05 11:16:06 +0000 touch: Fix setting time of created file if fstat() fails Previously, if creating the file and fstat() fails, we would've ended up calling utimensat() on that file anyways with whatever was in sb. Not that this is an error likely to happen... We don't check for the return value of close() as we aren't writing anything to the file and the file is always created on success of open(). Reviewed by: kevans Approved by: kevans Fixes: cb54c500d0e1 ("touch: don't leak descriptor if fstat(2) fails") Sponsored by: Klara, Inc. Differential Revision: https://reviews.freebsd.org/D55117 MFC after: 1 week --- usr.bin/touch/touch.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/usr.bin/touch/touch.c b/usr.bin/touch/touch.c index 70257e320a60..2be2e369596c 100644 --- a/usr.bin/touch/touch.c +++ b/usr.bin/touch/touch.c @@ -163,19 +163,14 @@ main(int argc, char *argv[]) /* Create the file. */ fd = open(*argv, O_WRONLY | O_CREAT, DEFFILEMODE); - if (fd == -1) { + if (fd < 0 || fstat(fd, &sb) < 0) { rval = 1; warn("%s", *argv); + if (fd >= 0) + (void)close(fd); continue; } - if (fstat(fd, &sb) < 0) { - warn("%s", *argv); - rval = 1; - } - if (close(fd) < 0) { - warn("%s", *argv); - rval = 1; - } + (void)close(fd); /* If using the current time, we're done. */ if (!timeset)