Add secure_getenv(3).
This commit is contained in:
parent
adc03f0170
commit
ef310421d7
3 changed files with 28 additions and 0 deletions
|
@ -191,6 +191,7 @@ stdlib/qsort.o \
|
|||
stdlib/qsort_r.o \
|
||||
stdlib/reallocarray.o \
|
||||
stdlib/realloc.o \
|
||||
stdlib/secure_getenv.o \
|
||||
stdlib/strtod.o \
|
||||
stdlib/strtof.o \
|
||||
stdlib/strtold.o \
|
||||
|
|
|
@ -144,6 +144,7 @@ int mkostemp(char*, int);
|
|||
int ptsname_r(int, char*, size_t);
|
||||
void qsort_r(void*, size_t, size_t, int (*)(const void*, const void*, void*), void*);
|
||||
void* reallocarray(void*, size_t, size_t);
|
||||
char* secure_getenv(const char*);
|
||||
#endif
|
||||
|
||||
#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