Date: Fri, 5 Oct 2012 09:47:54 +0000 (UTC) From: Jaakko Heinonen <jh@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r241222 - stable/9/sys/kern Message-ID: <201210050947.q959lsEa040469@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
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);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201210050947.q959lsEa040469>