Re: strscpy

Maxime Villard <[email protected]> Tue, 19 May 2020 07:38:58 +0200
Newsgroups gmane.os.netbsd.devel.security
Message-ID <[email protected]>
Le 19/05/2020 à 07:31, Maxime Villard a écrit :
> Le 18/05/2020 à 21:03, Martin Husemann a écrit :
>> On Mon, May 18, 2020 at 09:00:01PM +0200, Maxime Villard wrote:
>>> I believe this is why copystr(), although safer than strlcpy(), isn't used much:
>>> the length returned in a pointer is unusual.
>>
>> Isn't it used (nowadays) only in ~ a single place where it needs to be
>> congruent with copyinstr? And it could be totaly removed quite easily?
> 
> copystr() has a small dozen of users. Yes, it could be removed easily, but
> we need a better replacement first. I made this patch, the code is simple.
> 
>      https://m00nbsd.net/garbage/libkern/strscpy.diff

(Mmh, had put the wrong version of my diff, now it's the correct one; we return
either -EINVAL or -E2BIG on error)