Index: sys/kern/kern_environment.c =================================================================== --- sys/kern/kern_environment.c (revision 247765) +++ sys/kern/kern_environment.c (working copy) @@ -231,20 +231,23 @@ init_dynamic_kenv(void *data __unused) kenvp = malloc((KENV_SIZE + 1) * sizeof(char *), M_KENV, M_WAITOK | M_ZERO); i = 0; - for (cp = kern_envp; cp != NULL; cp = kernenv_next(cp)) { - len = strlen(cp) + 1; - if (len > KENV_MNAMELEN + 1 + KENV_MVALLEN + 1) { - printf("WARNING: too long kenv string, ignoring %s\n", - cp); - continue; + if (env_pos > 0) { + for (cp = kern_envp; cp != NULL; cp = kernenv_next(cp)) { + len = strlen(cp) + 1; + if (len > KENV_MNAMELEN + 1 + KENV_MVALLEN + 1) { + printf( + "WARNING: too long kenv string, ignoring %s\n", + cp); + continue; + } + if (i < KENV_SIZE) { + kenvp[i] = malloc(len, M_KENV, M_WAITOK); + strcpy(kenvp[i++], cp); + } else + printf( + "WARNING: too many kenv strings, ignoring %s\n", + cp); } - if (i < KENV_SIZE) { - kenvp[i] = malloc(len, M_KENV, M_WAITOK); - strcpy(kenvp[i++], cp); - } else - printf( - "WARNING: too many kenv strings, ignoring %s\n", - cp); } kenvp[i] = NULL;