Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 16 Apr 2013 22:09:08 +0000 (UTC)
From:      Warner Losh <imp@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r249570 - head/sys/kern
Message-ID:  <201304162209.r3GM98RO026879@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: imp
Date: Tue Apr 16 22:09:08 2013
New Revision: 249570
URL: http://svnweb.freebsd.org/changeset/base/249570

Log:
  r249408 and r249436 cause a NULL pointer dereference on the CUBIEBOARD
  since it doesn't set the kernel envrionment at all. Work around this
  by making sure kern_envp is non-NULL before dereferencing it.

Modified:
  head/sys/kern/kern_environment.c

Modified: head/sys/kern/kern_environment.c
==============================================================================
--- head/sys/kern/kern_environment.c	Tue Apr 16 21:26:44 2013	(r249569)
+++ head/sys/kern/kern_environment.c	Tue Apr 16 22:09:08 2013	(r249570)
@@ -231,7 +231,7 @@ init_dynamic_kenv(void *data __unused)
 	kenvp = malloc((KENV_SIZE + 1) * sizeof(char *), M_KENV,
 		M_WAITOK | M_ZERO);
 	i = 0;
-	if (*kern_envp != '\0') {
+	if (kern_envp && *kern_envp != '\0') {
 		for (cp = kern_envp; cp != NULL; cp = kernenv_next(cp)) {
 			len = strlen(cp) + 1;
 			if (len > KENV_MNAMELEN + 1 + KENV_MVALLEN + 1) {



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201304162209.r3GM98RO026879>