Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 15 Jul 2013 19:52:21 +0300
From:      Andriy Gapon <>
Subject:   Re: weird problem with git gui
Message-ID:  <>
In-Reply-To: <>
References:  <> <> <> <>

Next in thread | Previous in thread | Raw E-Mail | Index | Archive | Help
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:

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

Want to link to this message? Use this URL: <>