tech-toolchain archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: TOCTOU bug in make(1)
On Fri, Oct 07, 2022 at 10:19:44 +1300, Lloyd Parkes wrote:
> On 7/10/22 09:49, Joerg Sonnenberger wrote:
> > Am Fri, Oct 07, 2022 at 09:07:10AM +1300 schrieb Lloyd Parkes:
> > >
> > > That's a good point. Personally, I had forgotten that unlinking directories
> > > was a thing. We should put a comment in the code for unlink_file() about
> > > that.
> >
> > Well, if you read the code you should start to wonder why it does the
> > whole lstat + check for directory dance...
>
> Yeah, nah. Only people those few people who are actually still using antique
> Unix systems will be able to work this out. Everyone else will need to be
> psychic and that isn't an acceptable way to write code.
>
> This code is in the core NetBSD source tree (usr.bin/make) and the
> unlink_file() function has no use in NetBSD. This is intrinsically worth
> documenting.
>
> I have to admit that I sometimes wonder whether or not it is true that the
> bulk of the comments in the *BSD code base is in fact the BSD license
> repeated across each .c file. If we can spend 30 seconds typing in a one
> line comment that saves one person 15 minutes of head scratching, then we
> have already made our software more efficient as a code base to use.
It did have a comment, but it was removed in revision 1.548. It also,
unnecessarily, IMHO, decided to change the return type to a more
"modern" bool thus further obscuring the fact that the function was a
simple wrapper around unlink(2).
-uwe
Home |
Main Index |
Thread Index |
Old Index