Page MenuHomeFreeBSD

touch: Fix setting time of created file if fstat() fails
ClosedPublic

Authored by obiwac on Feb 4 2026, 9:20 PM.
Tags
None
Referenced Files
F163264873: D55117.id.diff
Tue, Jul 21, 2:05 PM
F163213980: D55117.id171179.diff
Tue, Jul 21, 3:05 AM
Unknown Object (File)
Mon, Jul 20, 4:23 PM
Unknown Object (File)
Sun, Jul 19, 6:47 PM
Unknown Object (File)
Sat, Jul 18, 11:49 PM
Unknown Object (File)
Sat, Jul 18, 9:05 PM
Unknown Object (File)
Sat, Jul 18, 3:30 AM
Unknown Object (File)
Wed, Jul 15, 7:06 AM
Subscribers

Details

Summary

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 created on success of open().

Fixes: cb54c500d0e1 ("touch: don't leak descriptor if fstat(2) fails")
Sponsored by: Klara, Inc.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 70419
Build 67302: arc lint + arc unit