This is the mail archive of the cygwin-developers@cygwin.com mailing list for the Cygwin 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: ntsec patch #4: passwd and group


On Mon, Nov 11, 2002 at 01:36:30PM -0500, Pierre A. Humblet wrote:
> Corinna Vinschen wrote:
> > But 2 is not an issue.  The appl. called getpwuid once and then the
> > static buffer contains data.  That's it. 
> 
> At this point the application may do an open (), stat () or setuid (), 
> intending to use the static buffer immediately after those calls
> (a likely scenario with setuid () ?). However those calls may invalidate 
> the pointers in the buffer.

I'm not sure if we're talking about the same static buffer.  What I'm
trying to say is, that (for instance) getpwuid() must provide it's
own static buffer to not collide with the changing passwd list:

So roughly it should work like this:

  struct passwd *getpwuid()
  {
    static struct passwd pw, *pwlist_ptr;
    static char buf[MAX_USEFUL_SIZE];

    if (pwlist_ptr = search_for (uid, 0))
      {
        copy_list_member_to_pw_buf (pwlist_ptr, &pw, buf);
	return &pw;
      }
    return NULL;
  }

The copy_list_member_to_pw_buf() function must apparently set the
correct pointer values in the pw struct to something pointing into
the local buf so I don't quite understand what you're up to.

Anyway, since the external getpwXXX and getgrXXX functions are
not independent from their siblings, they even may share the same
global static area.  SUSv3 says:

"The return value may point to a static area which is overwritten
 by a subsequent call to getpwent(), getpwnam(), or getpwuid()."

> I am not saying that this is a problem that needs immediate fixing,
> only that it is an area of non-compliance. We may want to pay attention
> to it when we revisit pw/gr to address the thread issues. 

To add another point, SUSv3 says:

"The getpwuid() function need not be reentrant. A function that is
 not required to be reentrant is not required to be thread-safe."

IMHO that means, we don't even have to care for the mutex thingy.
It's ok as it is.  Except for only the getpwuid_r() call.

> I thought I had sent them in November, after you came back 
> (after you sent the sshd update), but then you probably got a lot 
> to do those days. Nothing has changed on my side, could you pick them 
> up on the list? Thanks.

I'm sorry, I wasn't resubscribed until the 8th of November.  I'm
currently looking into #1.

Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Developer                                mailto:cygwin@cygwin.com
Red Hat, Inc.


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