Page MenuHomeFreeBSD

fts: Check link count before using it
ClosedPublic

Authored by des on Fri, May 29, 1:24 PM.
Tags
None
Referenced Files
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
Unknown Object (File)
Sat, Jun 6, 10:41 PM
Unknown Object (File)
Sat, Jun 6, 8:36 PM
Unknown Object (File)
Sat, Jun 6, 6:17 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.Fri, May 29, 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.Fri, May 29, 2:36 PM
This revision is now accepted and ready to land.Fri, May 29, 2:51 PM
This revision was automatically updated to reflect the committed changes.