Page MenuHomeFreeBSD

fts: Check link count before using it
ClosedPublic

Authored by des on May 29 2026, 1:24 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, Sep 13, 6:16 PM
Unknown Object (File)
Sun, Sep 13, 5:30 PM
Unknown Object (File)
Sun, Sep 13, 5:01 PM
Unknown Object (File)
Mon, Sep 7, 5:08 PM
Unknown Object (File)
Mon, Sep 7, 6:46 AM
Unknown Object (File)
Sun, Sep 6, 4:23 PM
Unknown Object (File)
Sun, Sep 6, 3:29 PM
Unknown Object (File)
Sun, Sep 6, 2:52 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 Skipped
Unit
Tests Skipped
Build Status
Buildable 73544
Build 70427: arc lint + arc unit

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.