aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKyle Evans <kevans@FreeBSD.org>2018-11-13 04:34:30 +0000
committerKyle Evans <kevans@FreeBSD.org>2018-11-13 04:34:30 +0000
commit75beb4d46ab3f2bf9e2de225f2079d37d1277c1e (patch)
treeb33bae3939996b7b5b776129c99a4169869c3d28
parent7ee126159f440a83674d693f799ad624d08e5229 (diff)
downloadsrc-75beb4d46ab3f2bf9e2de225f2079d37d1277c1e.tar.gz
src-75beb4d46ab3f2bf9e2de225f2079d37d1277c1e.zip
Add dynamic_kenv assertion to init_static_kenv
Both to formally document the requirement that this not be called after the dynamic kenv is setup, and to perhaps help static analyzers figure out what's going on. While calling init_static_kenv this late isn't fatal, there are some caveats that the caller should be aware of: - Late calls are effectively a no-op, as far as default FreeBSD is concerned, as everything will switch to searching the dynamic kenv once it's available. - Each of the kern_getenv calls will leak memory, as it's assumed that these are searching static environment and allocations will not be made. As such, this usage is not sensible and should be detected.
Notes
Notes: svn path=/head/; revision=340392
-rw-r--r--sys/kern/kern_environment.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/sys/kern/kern_environment.c b/sys/kern/kern_environment.c
index b8eebc217721..a2480c3d689e 100644
--- a/sys/kern/kern_environment.c
+++ b/sys/kern/kern_environment.c
@@ -249,6 +249,7 @@ init_static_kenv(char *buf, size_t len)
{
char *eval;
+ KASSERT(!dynamic_kenv, ("kenv: dynamic_kenv already initialized"));
/*
* Give the static environment a chance to disable the loader(8)
* environment first. This is done with loader_env.disabled=1.