On Thu, Jun 02, 2016 at 09:57:01PM +0200, FRIGN wrote:
> Hello fellow hackers,
> 
> I'll drop this little patch here so we finally make the switch to the
> safe OpenBSD-functions for string copying.

A good compromise might be using snprintf(buf, sizeof(buf), "%s", text) this is
standard and functionally exactly the same as using strlcpy.

I agree the strncpy functions need to go, they don't make sense in this
context.

Some people forget strncpy has the following properties aswell, from the
OpenBSD man page:

"If src is less than len characters long, it fills the remaining buffer
with '\0' characters".

and

"strncpy() only NUL terminates the destination string when the length of
the source string is less than the length parameter."

-- 
Kind regards,
Hiltjo

Reply via email to