Add secure_getenv(3).
This commit is contained in:
parent
0ff1b68c09
commit
b63e5af467
3 changed files with 28 additions and 0 deletions
|
@ -164,6 +164,7 @@ stdlib/qsort.o \
|
||||||
stdlib/qsort_r.o \
|
stdlib/qsort_r.o \
|
||||||
stdlib/reallocarray.o \
|
stdlib/reallocarray.o \
|
||||||
stdlib/realloc.o \
|
stdlib/realloc.o \
|
||||||
|
stdlib/secure_getenv.o \
|
||||||
stdlib/strtod.o \
|
stdlib/strtod.o \
|
||||||
stdlib/strtof.o \
|
stdlib/strtof.o \
|
||||||
stdlib/strtold.o \
|
stdlib/strtold.o \
|
||||||
|
|
|
@ -164,6 +164,7 @@ void* reallocarray_trace(struct __allocation_site*, void*, size_t, size_t);
|
||||||
#else
|
#else
|
||||||
void* reallocarray(void*, size_t, size_t);
|
void* reallocarray(void*, size_t, size_t);
|
||||||
#endif
|
#endif
|
||||||
|
char* secure_getenv(const char*);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(__is_sortix_libc)
|
#if defined(__is_sortix_libc)
|
||||||
|
|
26
libc/stdlib/secure_getenv.c
Normal file
26
libc/stdlib/secure_getenv.c
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2024 Jonas 'Sortie' Termansen.
|
||||||
|
*
|
||||||
|
* Permission to use, copy, modify, and distribute this software for any
|
||||||
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
|
* copyright notice and this permission notice appear in all copies.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||||
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||||
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
|
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||||
|
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||||
|
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
*
|
||||||
|
* stdlib/secure_getenv.c
|
||||||
|
* Get an environment variable securely.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
char* secure_getenv(const char* name)
|
||||||
|
{
|
||||||
|
// Sortix does not have setuid / setgid executables.
|
||||||
|
return getenv(name);
|
||||||
|
}
|
Loading…
Reference in a new issue