This is the mail archive of the libc-hacker@cygnus.com 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]

Re: nss buffers?


Hi,

Ulrich Drepper:
> smurf@noris.de (Matthias Urlichs) writes:
> 
> > I just noticed that a getspnam() call will trash the buffer used by a
> > previous getpwnam(). This caused wu-ftpd to break.
> 
> There shouldn't be any problem since nothing from the buffer is read.
> Of course you can't use the same buffer in both functions at the same
> time.
> 
That "of course" causes the breakage.

Actual code, paraphrased of course, found in more than one program:
...
	pw = getpwnam("foo");
	if(!pw) die();
	sp = getspnam(pw->pw_name);
	if(!check_password(sp ? sp->sp_pwdp ? pw->pw_passwd)) die();
	chdir(pw->pw_dir); /* Garbage */
...

I do think that this sequence is common enough that, if at all possible,
each class of get* functions should get its own buffer.

> shouldn't it be getspname_r and getpwnam_r?)

We're NOT talking about newly-written code here.

-- 
Matthias Urlichs  |  noris network GmbH   |   smurf@noris.de  |  ICQ: 20193661
The quote was selected randomly. Really.    |      http://www.noris.de/~smurf/
-- 
I turned my air conditioner the other way around, and it got cold out.  The
weatherman said, 'I don't understand it.  It was supposed to be 80 degrees
today.' and I said, 'Oops.'
                                               -- Steve Wright


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