This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH][BZ #13724] Do not segfault in pthread_setname_np (x, NULL)


On Thu, Oct 03, 2013 at 10:31:39AM -0400, Rich Felker wrote:
> On Thu, Oct 03, 2013 at 02:20:09PM +0200, OndÅej BÃlka wrote:
> > Hi, this is another bug that could be handled quickly. Problem is if 
> > pthread_setname_np (x, NULL) should return error code or segfault. 
> > (see https://sourceware.org/bugzilla/show_bug.cgi?id=13724 )
> > If first is desired then following patch does it. If we choose for
> > second then close that bugzilla entry.
> > 
> > 	* sysdeps/unix/sysv/linux/pthread_setname.c (pthread_setname_np):
> > 	Handle null.
> > 
> > diff --git a/nptl/sysdeps/unix/sysv/linux/pthread_setname.c b/nptl/sysdeps/unix/sysv/linux/pthread_setname.c
> > index d6455dd..45eefa0 100644
> > --- a/nptl/sysdeps/unix/sysv/linux/pthread_setname.c
> > +++ b/nptl/sysdeps/unix/sysv/linux/pthread_setname.c
> > @@ -34,6 +34,10 @@ pthread_setname_np (th, name)
> >  {
> >    const struct pthread *pd = (const struct pthread *) th;
> >  
> > +  /* Return EFAULT like pthread_getname_np(x, NULL, 16) does.  */
> > +  if (name == NULL)
> > +    return EFAULT;
> > +
> 
> Why? I see no reason it "should" do this. Passing an invalid pointer
> produces undefined behavior unless the behavior is documented as doing
> something useful.
> 

Why, I wrote above:

> > If first is desired then following patch does it. If we choose for
> > second then close that bugzilla entry.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]