Index | Thread | Search

From:
"Theo de Raadt" <deraadt@openbsd.org>
Subject:
Re: Maybe strlen is unnecessary in kern_unveil.c
To:
Sebastien Marie <semarie@kapouay.eu.org>
Cc:
Bob Beck <beck@obtuse.com>, Christian Schulte <cs@schulte.it>, tech@openbsd.org
Date:
Wed, 19 Nov 2025 10:00:32 -0700

Download raw body.

Thread
I've seen so much trouble from taking a buffer, which is not actually
a string, and start trying to add half-measures to NUL terminate or
or check for NUL-termination, so that is now kind of like a string.
Soon, someone dealing with the code sees those checks and starts to
believe it is a string but it isn't, and now a bug gets introduced,
and quite often these problems are related to the +1 accounting for
the NUL.  Like here :)

So my gut feeling has always been that if an object is a non-string buffer,
every single line of code should treat it like a non-string to avoid
the confusion.