[Openmp-commits] [openmp] 7fcfcf1 - [OpenMP] Use secure_getenv when read OMPT library path (#208652)
via Openmp-commits
openmp-commits at lists.llvm.org
Fri Jul 10 04:25:26 PDT 2026
Author: Jan Patrick Lehr
Date: 2026-07-10T13:25:21+02:00
New Revision: 7fcfcf1c5db1d46b6cc85b80be3a24ee887773f9
URL: https://github.com/llvm/llvm-project/commit/7fcfcf1c5db1d46b6cc85b80be3a24ee887773f9
DIFF: https://github.com/llvm/llvm-project/commit/7fcfcf1c5db1d46b6cc85b80be3a24ee887773f9.diff
LOG: [OpenMP] Use secure_getenv when read OMPT library path (#208652)
An internal review flagged the use of `getenv` when reading the OMPT
tool library path from the environment and passing it to the loader as a
potential vuln.
This patch replaces the use of getenv in question with the use of
secure_getenv on glibc platforms.
On non glibc platforms, no change is implemented.
Added:
Modified:
openmp/runtime/src/ompt-general.cpp
Removed:
################################################################################
diff --git a/openmp/runtime/src/ompt-general.cpp b/openmp/runtime/src/ompt-general.cpp
index a708a8d76fcf4..1682f7e74bd14 100644
--- a/openmp/runtime/src/ompt-general.cpp
+++ b/openmp/runtime/src/ompt-general.cpp
@@ -60,6 +60,12 @@
static FILE *verbose_file;
static int verbose_init;
+#if defined(__GLIBC__)
+#define OMPT_GETENV secure_getenv
+#else
+#define OMPT_GETENV getenv
+#endif
+
/*****************************************************************************
* types
****************************************************************************/
@@ -281,7 +287,7 @@ ompt_try_start_tool(unsigned int omp_version, const char *runtime_version) {
// Try tool-libraries-var ICV
OMPT_VERBOSE_INIT_CONTINUED_PRINT("Failed.\n");
- const char *tool_libs = getenv("OMP_TOOL_LIBRARIES");
+ const char *tool_libs = OMPT_GETENV("OMP_TOOL_LIBRARIES");
if (tool_libs) {
OMPT_VERBOSE_INIT_PRINT("Searching tool libraries...\n");
OMPT_VERBOSE_INIT_PRINT("OMP_TOOL_LIBRARIES = %s\n", tool_libs);
More information about the Openmp-commits
mailing list