Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 15 Jul 2013 18:56:16 +0200
From:      Pietro Cerutti <gahr@FreeBSD.org>
To:        Andriy Gapon <avg@FreeBSD.org>
Cc:        tcltk@FreeBSD.org
Subject:   Re: weird problem with git gui
Message-ID:  <20130715165616.GF21355@gahrfit.gahr.ch>
In-Reply-To: <51E428C5.8050000@FreeBSD.org>
References:  <51E3AD58.6030001@FreeBSD.org> <20130715083241.GB21355@gahrfit.gahr.ch> <51E416DF.6040903@FreeBSD.org> <51E4222B.8010605@FreeBSD.org> <51E428C5.8050000@FreeBSD.org>

Next in thread | Previous in thread | Raw E-Mail | Index | Archive | Help

--pQhZXvAqiZgbeUkD
Content-Type: text/plain; charset=utf-8
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On 2013-Jul-15, 19:52, Andriy Gapon wrote:
> on 15/07/2013 19:24 Andriy Gapon said the following:
> > on 15/07/2013 18:35 Andriy Gapon said the following:
> > [snip]
> >> I do not have any conclusions or solution, but i have some further obs=
ervations.
> >> It seems that in my environment tcl wants to manipulate 'environ' glob=
al
> >> variable directly instead of using putenv/setenv/etc.  I am not sure w=
hy this is
> >> preferred, but unix/tclUnixPort.h defines USE_PUTENV only for __CYGWIN=
__ or APPLE.
> > [snip]
> >>
> >> ... and now I also know why I have this problem on this particular mac=
hine!
> >> I have a patched version of libfreetype (print/freetype2 with custom
> >> 'infinality' patch).  So apparently the unmodified version does not ca=
ll setenv
> >> and so tcl has full control.  On the other hand with my version setenv=
 confuses tcl.
> >>
> >> I think that in general we should allow setenv to be called from beyon=
d tcl
> >> control even while under tcl interpreter.  So I consider this to be an=
 exotic
> >> bug in tcl.  Not sure how to proceed from here though.
> >>
> >=20
> > This patch seems to help me:
> [snip]
>=20
> And I think I found a bug in libc:
> commit e757a2e38f2b2f96136d2193c8f292d6aa552f6c
> Author: Andriy Gapon <avg@icyb.net.ua>
> Date:   Mon Jul 15 19:50:55 2013 +0300
>=20
>     libc: name passed into __setenv is not necessarily NUL-terminated
>=20
>     That's particularly true when __setenv is called from __merge_environ.
>=20
> diff --git a/lib/libc/stdlib/getenv.c b/lib/libc/stdlib/getenv.c
> index 47963d5..079b024 100644
> --- a/lib/libc/stdlib/getenv.c
> +++ b/lib/libc/stdlib/getenv.c
> @@ -505,7 +505,7 @@ __setenv(const char *name, size_t nameLen, const char
> *value, int overwrite)
>  		envVars[envNdx].valueSize =3D valueLen;
>=20
>  		/* Save name of name/value pair. */
> -		env =3D stpcpy(envVars[envNdx].name, name);
> +		env =3D stpncpy(envVars[envNdx].name, name, nameLen);
>  		if ((envVars[envNdx].name)[nameLen] !=3D '=3D')
>  			env =3D stpcpy(env, "=3D");
>  	}
>=20
>=20
> So, I think that tcl is not to blame at all.
> Sorry for the noise on tcltk@.

Thanks a lot for finding and fixing this! It would have caused me a lot
of head scratch to locate this starting from the Tcl interp :)

--=20
Pietro Cerutti
The FreeBSD Project
gahr@FreeBSD.org

PGP Public Key:
http://gahr.ch/pgp

--pQhZXvAqiZgbeUkD
Content-Type: application/pgp-signature

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.20 (FreeBSD)

iEYEARECAAYFAlHkKa8ACgkQwMJqmJVx945LBwCfQ93oHKHZfWo11v1Aija2WGYT
LXUAoJjSKm5DdoYl3RH+/nOGsfVP5fTe
=ZBo6
-----END PGP SIGNATURE-----

--pQhZXvAqiZgbeUkD--



Want to link to this message? Use this URL: <http://docs.FreeBSD.org/cgi/mid.cgi?20130715165616.GF21355>