lkml.org 
[lkml]   [2014]   [Sep]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] lib: string.c: Added a funktion function strzcpy
On Wed, Sep 24, 2014 at 07:35:55AM -0700, Andi Kleen wrote:
> On Wed, Sep 24, 2014 at 10:52:06AM +0300, Dan Carpenter wrote:
> > 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.
>
> Like where?
>

You're asking what would break if we switched every strncpy() to
strlcpy() but it's not an easy question to answer.

I've looked a lot at information leaks, but strings are still a blind
spot for my Smatch. My check only looks at normal variables, arrays.
Eventually I hope to fix this, of course.

I did a git search and Rickard has added some examples, but there were
definitely other places that rely strncpy() padding before.

regards,
dan carpenter



\
 
 \ /
  Last update: 2014-09-24 18:21    [W:0.072 / U:0.508 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site