From owner-svn-src-stable-9@FreeBSD.ORG Fri Oct 5 09:47:55 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 123C71065672; Fri, 5 Oct 2012 09:47:55 +0000 (UTC) (envelope-from jh@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id D761E8FC08; Fri, 5 Oct 2012 09:47:54 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q959lsPF040472; Fri, 5 Oct 2012 09:47:54 GMT (envelope-from jh@svn.freebsd.org) Received: (from jh@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q959lsEa040469; Fri, 5 Oct 2012 09:47:54 GMT (envelope-from jh@svn.freebsd.org) Message-Id: <201210050947.q959lsEa040469@svn.freebsd.org> From: Jaakko Heinonen Date: Fri, 5 Oct 2012 09:47:54 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r241222 - stable/9/sys/kern X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 05 Oct 2012 09:47:55 -0000 Author: jh Date: Fri Oct 5 09:47:54 2012 New Revision: 241222 URL: http://svn.freebsd.org/changeset/base/241222 Log: MFC r239257: Reserve room for the terminating NUL when setting or getting kernel environment variables. KENV_MNAMELEN and KENV_MVALLEN doesn't include space for the terminating NUL. Modified: stable/9/sys/kern/kern_environment.c Directory Properties: stable/9/sys/ (props changed) stable/9/sys/amd64/include/xen/ (props changed) stable/9/sys/boot/ (props changed) stable/9/sys/boot/i386/efi/ (props changed) stable/9/sys/boot/ia64/efi/ (props changed) stable/9/sys/boot/ia64/ski/ (props changed) stable/9/sys/boot/powerpc/boot1.chrp/ (props changed) stable/9/sys/boot/powerpc/ofw/ (props changed) stable/9/sys/cddl/contrib/opensolaris/ (props changed) stable/9/sys/conf/ (props changed) stable/9/sys/contrib/dev/acpica/ (props changed) stable/9/sys/contrib/octeon-sdk/ (props changed) stable/9/sys/contrib/pf/ (props changed) stable/9/sys/contrib/x86emu/ (props changed) stable/9/sys/dev/ (props changed) stable/9/sys/dev/e1000/ (props changed) stable/9/sys/dev/isp/ (props changed) stable/9/sys/dev/ixgbe/ (props changed) stable/9/sys/dev/puc/ (props changed) stable/9/sys/fs/ (props changed) stable/9/sys/fs/ntfs/ (props changed) stable/9/sys/modules/ (props changed) Modified: stable/9/sys/kern/kern_environment.c ============================================================================== --- stable/9/sys/kern/kern_environment.c Fri Oct 5 07:51:21 2012 (r241221) +++ stable/9/sys/kern/kern_environment.c Fri Oct 5 09:47:54 2012 (r241222) @@ -143,9 +143,9 @@ sys_kenv(td, uap) break; } - name = malloc(KENV_MNAMELEN, M_TEMP, M_WAITOK); + name = malloc(KENV_MNAMELEN + 1, M_TEMP, M_WAITOK); - error = copyinstr(uap->name, name, KENV_MNAMELEN, NULL); + error = copyinstr(uap->name, name, KENV_MNAMELEN + 1, NULL); if (error) goto done; @@ -176,8 +176,8 @@ sys_kenv(td, uap) error = EINVAL; goto done; } - if (len > KENV_MVALLEN) - len = KENV_MVALLEN; + if (len > KENV_MVALLEN + 1) + len = KENV_MVALLEN + 1; value = malloc(len, M_TEMP, M_WAITOK); error = copyinstr(uap->value, value, len, NULL); if (error) { @@ -389,10 +389,10 @@ setenv(const char *name, const char *val KENV_CHECK; namelen = strlen(name) + 1; - if (namelen > KENV_MNAMELEN) + if (namelen > KENV_MNAMELEN + 1) return (-1); vallen = strlen(value) + 1; - if (vallen > KENV_MVALLEN) + if (vallen > KENV_MVALLEN + 1) return (-1); buf = malloc(namelen + vallen, M_KENV, M_WAITOK); sprintf(buf, "%s=%s", name, value);