Messages in this thread | | | Date | Wed, 24 Sep 2014 10:52:06 +0300 | From | Dan Carpenter <> | Subject | Re: [PATCH] lib: string.c: Added a funktion function strzcpy |
| |
On Tue, Sep 23, 2014 at 06:17:53PM -0700, Andi Kleen wrote: > On Wed, Sep 24, 2014 at 12:13:36AM +0200, Rickard Strandqvist wrote: > > Added a function strzcpy which works the same as strncpy, > > but guaranteed to produce the trailing null character. > > Do we really need the bizarre strncpy padding semantics for anything? > Why not just use strlcpy?
We do need the padding in many places to prevent information leaks.
So we end up open coding the last NUL after so many of the strncpy() calls. And we're adding more NUL terminators all over the place now just to make the code easier to audit.
regards, dan carpenter
| |