Add secure_getenv(3).

This commit is contained in:
Jonas 'Sortie' Termansen 2024-06-23 23:31:37 +02:00
parent 0ff1b68c09
commit b63e5af467
3 changed files with 28 additions and 0 deletions

View File

@ -164,6 +164,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 \

View File

@ -164,6 +164,7 @@ void* reallocarray_trace(struct __allocation_site*, void*, size_t, size_t);
#else
void* reallocarray(void*, size_t, size_t);
#endif
char* secure_getenv(const char*);
#endif
#if defined(__is_sortix_libc)

View 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);
}