I wonder if the memory needs to be malloc'd or if the stack variables
in main() are okay.
Ken Jones
Rick Morris wrote:
>
> Hello all.
>
> I've found a bug in vchkpw. It tries to add 3 new environment
> variables, but uses the same buf for each one, which overwrites the
> previous values.
>
> >From the putenv() man page:
>
> The string pointed to by string becomes
> part of the environment, so altering the string changes
> the environment.
>
> Here's a small quick & dirty diff for a fix.
> Yes, I know, not optimal, but it works. I'm using the mysql version, so
> I also added a line to get the host name into the USER environment variable,
> for when I log client's new/cur directory spool sizes when they check their
> mail.
>
> diff ../../vpopmail-4.9.4/vchkpw.c vchkpw.c
> 240,242d239
> < char envbuf1[128];
> < char envbuf2[128];
> < char envbuf3[128];
> 352,356c349,351
> < scopy(envbuf1,"USER=",sizeof(envbuf1));
> < scat(envbuf1,pwent->pw_name,sizeof(envbuf1));
> < scat(envbuf1,"@",sizeof(envbuf1));
> < scat(envbuf1,GLhost,sizeof(envbuf1));
> < if (putenv(envbuf1) == -1)
> ---
> > scopy(buf,"USER=",sizeof(buf));
> > scat(buf,pwent->pw_name,sizeof(buf));
> > if (putenv(buf) == -1)
> 360,362c355,357
> < scopy(envbuf2,"HOME=",sizeof(envbuf2));
> < scat(envbuf2,pwent->pw_dir,sizeof(envbuf2));
> < if (putenv(envbuf2) == -1)
> ---
> > scopy(buf,"HOME=",sizeof(buf));
> > scat(buf,pwent->pw_dir,sizeof(buf));
> > if (putenv(buf) == -1)
> 366,367c361,362
> < scopy(envbuf3,"SHELL=NOLOGIN",sizeof(envbuf3));
> < if (putenv(envbuf3) == -1)
> ---
> > scopy(buf,"SHELL=NOLOGIN",sizeof(buf));
> > if (putenv(buf) == -1)
>
> --
> Rick Morris
> VP Network Administration
> Wamco Technologies Group
>
> Phone: (250) 386-5535
> Fax: (250) 386-5520