[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]


From: Eli Zaretskii
Subject: Re: $USERPROFILE for $HOME on W32
Date: Thu, 25 Nov 2004 23:45:18 +0200

> From: Stefan <address@hidden>
> Date: Thu, 25 Nov 2004 12:45:48 -0500
> Cc: address@hidden, Jason Rumney <address@hidden>
> >> +      /* Set dir and shell from environment variables. */
> >> +      strcpy (the_passwd.pw_dir, getenv ("HOME"));
> > What if strlen (getenv ("HOME")) >= sizeof (the_passwd.pw_dir)?
> Well, tough!
> This code is not new: it's just moved from one place to another so it's not
> a new problem.

Can you (or someone else) look at the w32 system headers and see how
struct passwd is defined there?  I looked at two implementations
(DJGPP and glibc on Debian GNU/Linux), and they both define pw_dir and
pw_shell as `char *'.  So using strcpy here might mean a disaster, as
no memory could have been allocated for them; I'd use strdup instead.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]