From 5a7712975187899de45387cf470488ea6b3e8a37 Mon Sep 17 00:00:00 2001 From: liyunfei Date: Fri, 9 Aug 2024 17:12:14 +0800 Subject: [PATCH] Prevent environment variables from exceeding NAME_MAX (cherry picked from commit 4996d19ff15e056b817dc50067b6ea52669c5f24) --- ...ent-variables-from-exceeding-NAME_MA.patch | 28 +++++++++++++++++++ llvm.spec | 7 +++-- 2 files changed, 33 insertions(+), 2 deletions(-) create mode 100644 0022-Prevent-environment-variables-from-exceeding-NAME_MA.patch diff --git a/0022-Prevent-environment-variables-from-exceeding-NAME_MA.patch b/0022-Prevent-environment-variables-from-exceeding-NAME_MA.patch new file mode 100644 index 0000000..35043e2 --- /dev/null +++ b/0022-Prevent-environment-variables-from-exceeding-NAME_MA.patch @@ -0,0 +1,28 @@ +From 4673c2eaba443678c4dc6ae74ea16a489b415fed Mon Sep 17 00:00:00 2001 +From: liyunfei +Date: Tue, 19 Sep 2023 09:31:43 +0800 +Subject: [PATCH] Prevent environment variables from exceeding NAME_MAX + +--- + llvm/lib/Support/Unix/Path.inc | 6 +++++- + 1 file changed, 5 insertions(+), 1 deletion(-) + +diff --git a/llvm/lib/Support/Unix/Path.inc b/llvm/lib/Support/Unix/Path.inc +index 2ae7c6dc..f13f3165 100644 +--- a/llvm/lib/Support/Unix/Path.inc ++++ b/llvm/lib/Support/Unix/Path.inc +@@ -1427,8 +1427,12 @@ static const char *getEnvTempDir() { + // variable. + const char *EnvironmentVariables[] = {"TMPDIR", "TMP", "TEMP", "TEMPDIR"}; + for (const char *Env : EnvironmentVariables) { +- if (const char *Dir = std::getenv(Env)) ++ if (const char *Dir = std::getenv(Env)) { ++ if(std::strlen(Dir) > NAME_MAX) { ++ continue; ++ } + return Dir; ++ } + } + + return nullptr; +-- \ No newline at end of file diff --git a/llvm.spec b/llvm.spec index 5adfcb9..6213c6e 100644 --- a/llvm.spec +++ b/llvm.spec @@ -44,7 +44,7 @@ Name: %{pkg_name} Version: %{maj_ver}.%{min_ver}.%{patch_ver} -Release: 13 +Release: 14 Summary: The Low Level Virtual Machine License: NCSA @@ -75,8 +75,8 @@ Patch17: 0017-Add-the-support-for-classic-flang.patch Patch18: 0018-Fix-declaration-definition-mismatch-for-classic-flang.patch Patch19: 0019-Backport-LoongArch-Improve-the-support-for-atomic-and-clear_cache.patch Patch20: 0020-Update-llvm-lit-config-to-support-build_for_openeule.patch - Patch21: 0021-Add-BiSheng-Autotuner-support-for-LLVM-compiler.patch +Patch22: 0022-Prevent-environment-variables-from-exceeding-NAME_MA.patch BuildRequires: binutils-devel BuildRequires: cmake @@ -371,6 +371,9 @@ LD_LIBRARY_PATH=%{buildroot}/%{install_libdir} %{__ninja} check-all -C ./_build %{install_includedir}/llvm-gmock %changelog +* Mon Jul 22 2024 liyunfei - 17.0.6-14 +- Prevent environment variables from exceeding NAME_MAX. + * Mon Jul 22 2024 liyunfei - 17.0.6-13 - Disable toolchain_clang build for BiSheng Autotuner support temporary. -- Gitee