AIX usrinfo() cleanup.

Gert Doering gert at greenie.muc.de
Fri Jul 5 01:45:07 EST 2002


Hi,

On Thu, Jul 04, 2002 at 10:41:20AM -0500, troy wrote:
> > -	cp = xmalloc(22 + strlen(tty) + 2 * strlen(pw->pw_name));
> > -	i = sprintf(cp, "LOGNAME=%s%cNAME=%s%cTTY=%s%c%c", pw->pw_name, 0,
> > -	    pw->pw_name, 0, tty, 0, 0);
> > +	cp = xmalloc(16 + 2 * strlen(pw->pw_name));
> > +	i = sprintf(cp, "LOGNAME=%s%cNAME=%s%c%c", pw->pw_name, 0,
> > +	    pw->pw_name, 0, 0);
> 
> Doesn't sprintf add a trailing NULL to the end?  Don't you need to
> xmalloc(16+2*strlen(pw->pw_name)+1)?

Indeed.  The new string is 5 (plus strlen(tty)) characters shorter, not 6.

gert
-- 
USENET is *not* the non-clickable part of WWW!
                                                           //www.muc.de/~gert/
Gert Doering - Munich, Germany                             gert at greenie.muc.de
fax: +49-89-35655025                        gert.doering at physik.tu-muenchen.de



More information about the openssh-unix-dev mailing list