AIX usrinfo() cleanup.

troy troy at shun.org
Fri Jul 5 01:41:20 EST 2002


Quoting Ben Lindstrom (mouring at etoh.eviladmin.org):
> This is what I'm commiting.  Test it and tell me if I broke something.
> 
> RCS file: /var/cvs/openssh/openbsd-compat/port-aix.c,v
> retrieving revision 1.3
> diff -u -r1.3 port-aix.c
> --- openbsd-compat/port-aix.c	21 Jun 2002 00:01:19 -0000	1.3
> +++ openbsd-compat/port-aix.c	3 Jul 2002 23:21:36 -0000
[snip]
> -	if (ttyfd == -1)
> -		tty[0] = '\0';
> -	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)?

-- 
GPG keyid=4C04D07A
GPG fingerprint=A63A 4719 C7D6 0BF7 B487  7B4C 2B38 487B 4C04 D07A



More information about the openssh-unix-dev mailing list