Page MenuHomeFreeBSD

fts: Check link count before using it
ClosedPublic

Authored by des on May 29 2026, 1:24 PM.
Tags
None
Referenced Files
F161696218: D57324.diff
Mon, Jul 6, 12:57 AM
Unknown Object (File)
Sat, Jul 4, 5:20 AM
Unknown Object (File)
Tue, Jun 30, 2:27 AM
Unknown Object (File)
Sat, Jun 20, 3:27 PM
Unknown Object (File)
Sat, Jun 20, 1:11 PM
Unknown Object (File)
Wed, Jun 17, 8:27 PM
Unknown Object (File)
Tue, Jun 16, 1:16 PM
Unknown Object (File)
Sun, Jun 7, 12:15 AM
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.