From owner-svn-src-head@FreeBSD.ORG Wed Jul 17 04:19:02 2013 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id E968A762 for ; Wed, 17 Jul 2013 04:19:02 +0000 (UTC) (envelope-from mailer-daemon@vniz.net) Received: from mail-la0-f49.google.com (mail-la0-f49.google.com [209.85.215.49]) by mx1.freebsd.org (Postfix) with ESMTP id 7290B2BD for ; Wed, 17 Jul 2013 04:19:01 +0000 (UTC) Received: by mail-la0-f49.google.com with SMTP id ea20so1125568lab.22 for ; Tue, 16 Jul 2013 21:19:01 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:openpgp:content-type :content-transfer-encoding:x-gm-message-state; bh=4t5P26ZFdGQDSPY5V4ObjTUicKKj0O0z0wJk90M2AtA=; b=NP18P0KnAgC8uc4KyljFZnK6fwSM+D9g05Jlvh9U+KDZJhKdjOREBaXLqipGELiFpU 2WMsidCCU5MOoUMQk/gD52HHB9/R1Lezj9Xyr0d2OxaWTQkJrxR6FESf2wUpKxrnUC9W a97mBA8kyzGr1pr4pHo13+RfOIU60qaE2IKv1cP7b055dI3+c51C6ehp++LrPasITFF7 VtoTvXrYhpRlovGCE2MalW5xccX0ubdcEnj0Q5bW6mGZwqG+rmthcdl4ngTWChyJnl/8 3VQI35G/xtLAak8VcMYR0OiREgw609F5dM68Y/EB+VxU8MGkl70CQWxNYcvWu0OhxdFt Imaw== X-Received: by 10.112.63.2 with SMTP id c2mr2367779lbs.6.1374034260385; Tue, 16 Jul 2013 21:11:00 -0700 (PDT) Received: from [192.168.1.2] ([89.169.173.68]) by mx.google.com with ESMTPSA id am8sm1630489lac.1.2013.07.16.21.10.59 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 16 Jul 2013 21:10:59 -0700 (PDT) Message-ID: <51E61950.5090206@freebsd.org> Date: Wed, 17 Jul 2013 08:10:56 +0400 From: Andrey Chernov User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20130620 Thunderbird/17.0.7 MIME-Version: 1.0 To: Andriy Gapon Subject: Re: svn commit: r253380 - head/lib/libc/stdlib References: <201307160726.r6G7QlwE045679@svn.freebsd.org> In-Reply-To: <201307160726.r6G7QlwE045679@svn.freebsd.org> OpenPGP: id=964474DD Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Gm-Message-State: ALoCoQnIK3DSuct7AP4msZG8Fx4gCA8Z89yG8yXUWZ0FmPxL8rPT6MleeSgGJFJ31q02h01toO0V Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 17 Jul 2013 04:19:03 -0000 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. 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. -- http://ache.vniz.net/ bitcoin:1G6ugdNY6e5jx1GVnAU2ntj2NEfmjKG85r