diff options
| author | lucy <seafork@disroot.org> | 2023-03-13 22:01:12 +0000 |
|---|---|---|
| committer | Warner Losh <imp@FreeBSD.org> | 2023-03-14 04:19:24 +0000 |
| commit | adeca21464d25bc61f98968a5c1e76ab3c808ae4 (patch) | |
| tree | 7fbe26ffc73968e41068ad9f9a822378b461c850 /lib/libc/stdlib/getenv.c | |
| parent | 4f7b3120bc6049df3b1eabb4fca40b02294aace6 (diff) | |
Diffstat (limited to 'lib/libc/stdlib/getenv.c')
| -rw-r--r-- | lib/libc/stdlib/getenv.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/libc/stdlib/getenv.c b/lib/libc/stdlib/getenv.c index 7ca27ab710c4..86a846d58c69 100644 --- a/lib/libc/stdlib/getenv.c +++ b/lib/libc/stdlib/getenv.c @@ -448,6 +448,18 @@ getenv(const char *name) /* + * Runs getenv() unless the current process is tainted by uid or gid changes, in + * which case it will return NULL. + */ +char * +secure_getenv(const char *name) +{ + if (issetugid()) + return NULL; + return getenv(name); +} + +/* * Set the value of a variable. Older settings are labeled as inactive. If an * older setting has enough room to store the new value, it will be reused. No * previous variables are ever freed here to avoid causing a segmentation fault |
