HomeFreeBSD

When compacting directories, ufs_direnter() always trusted DIRSIZ()
rS82334Unpublished

Unpublished Commit ยท Learn More

No further details are available.

Description

When compacting directories, ufs_direnter() always trusted DIRSIZ()
to supply the number of bytes to be bcopy()'d to move an entry. If
d_ino == 0 however, DIRSIZ() is not guaranteed to return a sensible
length, so ufs_direnter could end up corrupting a directory during
compaction. In practice I believe this can only happen after fsck_ffs
has fixed a previously-corrupted directory.

We now deal with any mid-block unused entries specially to avoid
using DIRSIZ() or bcopy() on such entries. We also ensure that the
variables 'dsize' and 'spacefree' contain meaningful values at all
times. Add a few comments to describe better this intricate piece
of code.

The special handling of mid-block unused entries makes the dirhash-
specific bugfix in the previous revision (1.53) now uncecessary,
so this change removes it.

Reviewed by: mckusick

Details

Provenance
iedowseAuthored on
Parents
rS82333: Put a parenthesis in the right place (DUH!).
Branches
Unknown
Tags
Unknown

Event Timeline