From owner-svn-src-all@FreeBSD.ORG Wed Jul 17 08:24:59 2013 Return-Path: Delivered-To: svn-src-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 787D0230; Wed, 17 Jul 2013 08:24:59 +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 28D94C68; Wed, 17 Jul 2013 08:24:57 +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 LAA28429; Wed, 17 Jul 2013 11:24:56 +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 1UzN2e-000Pq7-1c; Wed, 17 Jul 2013 11:24:56 +0300 Message-ID: <51E654B3.4030000@FreeBSD.org> Date: Wed, 17 Jul 2013 11:24:19 +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: Andrey Chernov Subject: Re: svn commit: r253380 - head/lib/libc/stdlib References: <201307160726.r6G7QlwE045679@svn.freebsd.org> <51E61950.5090206@freebsd.org> In-Reply-To: <51E61950.5090206@freebsd.org> X-Enigmail-Version: 1.5.1 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Cc: svn-src-head@FreeBSD.org, svn-src-all@FreeBSD.org, src-committers@FreeBSD.org X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 17 Jul 2013 08:24:59 -0000 on 17/07/2013 07:10 Andrey Chernov said the following: > On 16.07.2013 11:26, Andriy Gapon wrote: >> Modified: head/lib/libc/stdlib/getenv.c >> ============================================================================== >> --- head/lib/libc/stdlib/getenv.c Tue Jul 16 06:50:22 2013 (r253379) >> +++ head/lib/libc/stdlib/getenv.c Tue Jul 16 07:26:46 2013 (r253380) >> @@ -505,7 +505,7 @@ __setenv(const char *name, size_t nameLe >> 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, "="); >> } >> > > I am not sure what you are trying to fix, but you just made next line > condition unpredictable random, since (envVars[envNdx].name)[nameLen] is > never filled now and there is freshly malloced memory content, which is > picked for != '=' comparison. I completely overlooked that check. Thank you for spotting the problema dn sorry for any potential breakage. I will fix this ASAP. > Please back it out or fix. Bug demonstration example added will be nice > too, I see no bug in the original code at first glance. Sorry if the commit message was not descriptive enough. I think that this thread should add some context to it: http://lists.freebsd.org/pipermail/freebsd-tcltk/2013-July/000075.html Do we already have some regression tests for environment manipulations? I could add a test for the bug I encountered. -- Andriy Gapon