opnsense-src/usr.bin/touch
Aymeric Wibo 69a3d9ab80
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:	cb54c500d0 ("touch: don't leak descriptor if fstat(2) fails")
Sponsored by:	Klara, Inc.
Differential Revision:	https://reviews.freebsd.org/D55117
MFC after: 1 week

(cherry picked from commit b8d55a86995b5a8db5d1651c8dc9fc5093b67d2c)
2026-02-17 14:14:14 +01:00
..
tests Update Makefile.depend files 2024-10-14 10:26:17 -07:00
Makefile touch: Add unit tests. 2024-03-27 11:03:45 +01:00
Makefile.depend Remove $FreeBSD$: one-line sh pattern 2023-08-16 11:55:03 -06:00
touch.1 usr.bin: Remove ancient SCCS tags. 2023-11-26 22:23:30 -07:00
touch.c touch: Fix setting time of created file if fstat() fails 2026-02-17 14:14:14 +01:00