From owner-freebsd-tcltk@FreeBSD.ORG Mon Jul 15 16:56:22 2013 Return-Path: Delivered-To: tcltk@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 4CA9542D; Mon, 15 Jul 2013 16:56:22 +0000 (UTC) (envelope-from gahr@FreeBSD.org) Received: from cpanel09.rubas.ch (cpanel09.rubas.ch [195.182.222.79]) by mx1.freebsd.org (Postfix) with ESMTP id 0AC93AF6; Mon, 15 Jul 2013 16:56:21 +0000 (UTC) Received: from 98-41.199-178.cust.bluewin.ch ([178.199.41.98]:64989 helo=gahrfit.gahr.ch) by cpanel09.rubas.ch with esmtpsa (TLSv1:DHE-RSA-AES256-SHA:256) (Exim 4.80.1) (envelope-from ) id 1Uym4R-002jmx-CF; Mon, 15 Jul 2013 18:56:19 +0200 Date: Mon, 15 Jul 2013 18:56:16 +0200 From: Pietro Cerutti To: Andriy Gapon Subject: Re: weird problem with git gui Message-ID: <20130715165616.GF21355@gahrfit.gahr.ch> References: <51E3AD58.6030001@FreeBSD.org> <20130715083241.GB21355@gahrfit.gahr.ch> <51E416DF.6040903@FreeBSD.org> <51E4222B.8010605@FreeBSD.org> <51E428C5.8050000@FreeBSD.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="pQhZXvAqiZgbeUkD" Content-Disposition: inline In-Reply-To: <51E428C5.8050000@FreeBSD.org> X-PGP-Key: 0x9571F78E X-PGP-Fingerprint: 1203 92B5 3919 AF84 9B97 28D6 C0C2 6A98 9571 F78E User-Agent: Mutt/1.5.21 (2010-09-15) X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - cpanel09.rubas.ch X-AntiAbuse: Original Domain - freebsd.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - FreeBSD.org X-Get-Message-Sender-Via: cpanel09.rubas.ch: authenticated_id: gahr@gahr.ch Cc: tcltk@FreeBSD.org X-BeenThere: freebsd-tcltk@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: gahr@FreeBSD.org List-Id: FreeBSD-specific Tcl/Tk discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 15 Jul 2013 16:56:22 -0000 --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 > 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--