"GOT", but the "O" is a cute, smiling pufferfish. Index | Thread | Search

From:
Stefan Sperling <stsp@stsp.name>
Subject:
Re: readdir() checks for . and ..
To:
Omar Polo <op@omarpolo.com>
Cc:
gameoftrees@openbsd.org
Date:
Sat, 31 May 2025 21:55:24 +0200

Download raw body.

Thread
On Sat, May 31, 2025 at 07:37:32PM +0200, Omar Polo wrote:
> decided to take a look due to other patches in other places :)
> 
> out of these, the only place where I feel like the "." and ".." checks
> were missing is in write_tree() -- all the others use
> got_repo_is_packidx_filename() which will obviously fail for those
> entries.
> 
> what do you think?

The loop in write_tree you are modifying is iterating over a custom
path list which uses selected dirents at specific offsets.
The . and .. entries were already filtered out when this list was
built in the loop above. The directory's contents should remain the
same until we close our directory handle.

As for the other places, sure. I don't see harm in adding those checks.
They seem idiomatic and I suppose some readers of this code will be
expecting to see them.