From nobody Thu Feb 5 11:17:12 2026 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 4f6F6w6W4Vz6FThH for ; Thu, 05 Feb 2026 11:17:12 +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 4f6F6w46W2z3lbH for ; Thu, 05 Feb 2026 11:17:12 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1770290232; 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=udyDML6o5WfxtkIV0i3sROTj9auBDVL3fF5gtbpRyVm5ClsEX6yJjPLz93UHvLcD/O+mD8 jR/+ITLp3lXlc4tVN0+f9iukaz8b0Z4N656uXWW+UgAKqpau2Loq+jRmXc7lL7rpnN62x2 xSsuu6ECjIG4RdMGsJrs1rEn7EgVnh/9DiTyZSV9fzFOOBx7rbgKiEUxKexSPj/odXtJcm 057bofgS1t6Jkr1iV9T/85znPUqfoK//RsWXdu9OTxWGY4bd+QsszBzkGPDKRNcS7z6cFr KtPmJiD23t+G7YmlmkECICHwS1TWgS0lBwbHfkapHx1TNkWb7cks+5Vp/osyZQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1770290232; a=rsa-sha256; cv=none; b=IZDtCn5kx1/phMIJN3v4UBlxqaCwyh93E0yGkp6SZllodsnsHfx0FHG4fidebeHw/oW8xe dKTQiHYywTQEFdzqqc801Fllm9IEFvERQYdohsJLFZ7rxbWaQboc+/rsb38LCv8Y9iTAz2 U33rqbYNbUuMWTRCWrosVRBOZvGt0Y+UoPcUrdgbH+n6o+w2qtFJFUAgdPaYwFy6f5icR6 NoNjj2KuQ7Ts7jXv6BzK5NniN+4xd2IMDVovLhf/T/wojf8Du/RQi0tpjANxAHJnConT92 BaPpyE/u2wQwVH0J/ynI3EkAhTKQaIzbRxAJIu5gvrRLnOzRu02jhzJV7RJ7nQ== 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=1770290232; 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=irolhOlU351ACPpzR5mWiqlJt5q4cqt60QCAWsV/9kOyRiq07WilbRiOVNGCjxtpKO0qtz zIrS4CWVcdci7+XLcLuPgTX7OsLQAe9Fwl+GZ5iPC96vEnxgThr8wcv+HHm6eDrxBlgxoX ButEi+OWyFNON+VewZJmFOA43gtwVSTafrZZHjbgPImPvo/cjINaWbpnSAmacZQ8j8rFd2 U2xKR80pjr7Y/WiwrvCBKgmuNVwPCK1r+ebwt0lnne3HEZs53WkEAC572wScN0WlHxkKac Pr+Q+gMddgMuynKCZvHWl0kMojVFUikJump78GNASruMJwEA5IgJraVRkhaNWg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4f6F6w3QDGzBJQ for ; Thu, 05 Feb 2026 11:17:12 +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 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: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@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)