From ec4d013e82fdb54f6e0163d952da794aa95fb14c 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: (cherry picked from commit 8b209a62006ad6fd4593bb4f528ce8aee23fc038) --- .pick_status.json | 2 +- meson.build | 1 + src/util/u_debug.h | 8 ++++++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/.pick_status.json b/.pick_status.json index 843b2d57bb3..6c88cc4882e 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -104,7 +104,7 @@ "description": "util: Provide a secure_getenv fallback for platforms without it", "nominated": false, "nomination_type": 3, - "resolution": 4, + "resolution": 1, "main_sha": null, "because_sha": null, "notes": null diff --git a/meson.build b/meson.build index a53d50d036d..1c8667a8fce 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) \