From owner-freebsd-tcltk@FreeBSD.ORG Mon Jul 15 16:53:00 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 A2EE43C3; Mon, 15 Jul 2013 16:53:00 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from citadel.icyb.net.ua (citadel.icyb.net.ua [212.40.38.140]) by mx1.freebsd.org (Postfix) with ESMTP id B9F67AC4; Mon, 15 Jul 2013 16:52:59 +0000 (UTC) Received: from porto.starpoint.kiev.ua (porto-e.starpoint.kiev.ua [212.40.38.100]) by citadel.icyb.net.ua (8.8.8p3/ICyb-2.3exp) with ESMTP id TAA17199; Mon, 15 Jul 2013 19:52:58 +0300 (EEST) (envelope-from avg@FreeBSD.org) Received: from localhost ([127.0.0.1]) by porto.starpoint.kiev.ua with esmtp (Exim 4.34 (FreeBSD)) id 1Uym1B-000Gv9-UW; Mon, 15 Jul 2013 19:52:57 +0300 Message-ID: <51E428C5.8050000@FreeBSD.org> Date: Mon, 15 Jul 2013 19:52:21 +0300 From: Andriy Gapon User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:17.0) Gecko/20130708 Thunderbird/17.0.7 MIME-Version: 1.0 To: gahr@FreeBSD.org Subject: Re: weird problem with git gui References: <51E3AD58.6030001@FreeBSD.org> <20130715083241.GB21355@gahrfit.gahr.ch> <51E416DF.6040903@FreeBSD.org> <51E4222B.8010605@FreeBSD.org> In-Reply-To: <51E4222B.8010605@FreeBSD.org> X-Enigmail-Version: 1.5.1 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Cc: tcltk@FreeBSD.org X-BeenThere: freebsd-tcltk@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list 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:53:00 -0000 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 observations. >> It seems that in my environment tcl wants to manipulate 'environ' global >> variable directly instead of using putenv/setenv/etc. I am not sure why 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 machine! >> I have a patched version of libfreetype (print/freetype2 with custom >> 'infinality' patch). So apparently the unmodified version does not call 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 beyond 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. >> > > This patch seems to help me: [snip] And I think I found a bug in libc: commit e757a2e38f2b2f96136d2193c8f292d6aa552f6c Author: Andriy Gapon Date: Mon Jul 15 19:50:55 2013 +0300 libc: name passed into __setenv is not necessarily NUL-terminated That's particularly true when __setenv is called from __merge_environ. 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 = valueLen; /* Save name of name/value pair. */ - env = stpcpy(envVars[envNdx].name, name); + env = stpncpy(envVars[envNdx].name, name, nameLen); if ((envVars[envNdx].name)[nameLen] != '=') env = stpcpy(env, "="); } So, I think that tcl is not to blame at all. Sorry for the noise on tcltk@. -- Andriy Gapon