From 5792c9802e748285fe93f0aa2636862a24967a85 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 --- ...ent-variables-from-exceeding-NAME_MA.patch | 28 +++++++++++++++++++ llvm.spec | 6 +++- 2 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 0021-Prevent-environment-variables-from-exceeding-NAME_MA.patch diff --git a/0021-Prevent-environment-variables-from-exceeding-NAME_MA.patch b/0021-Prevent-environment-variables-from-exceeding-NAME_MA.patch new file mode 100644 index 0000000..35043e2 --- /dev/null +++ b/0021-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 73dfde2..fefe0e1 100644 --- a/llvm.spec +++ b/llvm.spec @@ -38,7 +38,7 @@ Name: %{pkg_name} Version: %{maj_ver}.%{min_ver}.%{patch_ver} -Release: 10 +Release: 11 Summary: The Low Level Virtual Machine License: NCSA @@ -69,6 +69,7 @@ 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-Prevent-environment-variables-from-exceeding-NAME_MA.patch BuildRequires: binutils-devel BuildRequires: cmake @@ -353,6 +354,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-11 +- Prevent environment variables from exceeding NAME_MAX. + * Mon Apr 29 2024 wangqiang - 17.0.6-10 - Update llvm-lit config to support macro `build_for_openeuler` -- Gitee