From 8b209a62006ad6fd4593bb4f528ce8aee23fc038 Mon Sep 17 00:00:00 2001 From: Friedrich Vock Date: Wed, 31 Jan 2024 12:26:58 +0100 Subject: [PATCH] util: Provide a secure_getenv fallback for platforms without it Part-of: --- meson.build | 1 + src/util/u_debug.h | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/meson.build b/meson.build index a8d84c00b20..28c723410e1 100644 --- a/meson.build +++ b/meson.build @@ -1378,6 +1378,7 @@ functions_to_detect = { 'getrandom': '', 'qsort_s': '', 'posix_fallocate': '', + 'secure_getenv': '', } foreach f, prefix: functions_to_detect diff --git a/src/util/u_debug.h b/src/util/u_debug.h index 2f1a2dabed1..8e8319c0601 100644 --- a/src/util/u_debug.h +++ b/src/util/u_debug.h @@ -39,6 +39,7 @@ #define U_DEBUG_H_ #include +#include #include #if !defined(_WIN32) #include @@ -403,6 +404,13 @@ __normal_user(void) #endif } +#ifndef HAVE_SECURE_GETENV +static inline char *secure_getenv(const char *name) +{ + return getenv(name); +} +#endif + #define DEBUG_GET_ONCE_BOOL_OPTION(sufix, name, dfault) \ static bool \ debug_get_option_ ## sufix (void) \