Page MenuHomeFreeBSD

fts: Check link count before using it
ClosedPublic

Authored by des on May 29 2026, 1:24 PM.
Tags
None
Referenced Files
F166334303: D57324.id178933.diff
Wed, Aug 12, 11:41 PM
Unknown Object (File)
Tue, Aug 11, 6:57 PM
Unknown Object (File)
Sun, Aug 9, 7:43 PM
Unknown Object (File)
Sun, Aug 9, 4:08 PM
Unknown Object (File)
Sun, Aug 9, 6:21 AM
Unknown Object (File)
Sat, Aug 8, 10:42 PM
Unknown Object (File)
Fri, Aug 7, 8:08 PM
Unknown Object (File)
Fri, Aug 7, 7:43 PM
Subscribers

Details

Summary
  • Check the range of the link count before trying to use it.
  • Rewrite the comment explaining what the link count is used for.

MFC after: 1 week
Sponsored by: Klara, Inc.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

des requested review of this revision.May 29 2026, 1:24 PM
kevans added inline comments.
lib/libc/gen/fts.c
739

Pre-existing issue and a little pedantic, but this should probably at least be long long on FreeBSD to be correct for the remaining 32-bit arch we have? __nlink_t is unconditionally a uint64_t, so we have some range of values that might misbehave in presumably pathological cases. I probably would've gone with nlink_t and special-cased (nlink_t)-1, though. Losing one potential valid value for a link count seems fine, especially in light of your note that NLINK_MAX might be a truncated value anyways and we have to be conservative with it.

des marked an inline comment as done.May 29 2026, 2:36 PM
This revision is now accepted and ready to land.May 29 2026, 2:51 PM
This revision was automatically updated to reflect the committed changes.