Prevent environment variables from exceeding NAME_MAX

This commit is contained in:
liyunfei 2024-08-09 17:12:14 +08:00 committed by xiajingze
parent ce062ba57a
commit 4996d19ff1
2 changed files with 33 additions and 2 deletions

View File

@ -0,0 +1,28 @@
From 4673c2eaba443678c4dc6ae74ea16a489b415fed Mon Sep 17 00:00:00 2001
From: liyunfei <liyunfei33@huawei.com>
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;
--

View File

@ -44,7 +44,7 @@
Name: %{pkg_name} Name: %{pkg_name}
Version: %{maj_ver}.%{min_ver}.%{patch_ver} Version: %{maj_ver}.%{min_ver}.%{patch_ver}
Release: 13 Release: 14
Summary: The Low Level Virtual Machine Summary: The Low Level Virtual Machine
License: NCSA 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 Patch18: 0018-Fix-declaration-definition-mismatch-for-classic-flang.patch
Patch19: 0019-Backport-LoongArch-Improve-the-support-for-atomic-and-clear_cache.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 Patch20: 0020-Update-llvm-lit-config-to-support-build_for_openeule.patch
Patch21: 0021-Add-BiSheng-Autotuner-support-for-LLVM-compiler.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: binutils-devel
BuildRequires: cmake BuildRequires: cmake
@ -371,6 +371,9 @@ LD_LIBRARY_PATH=%{buildroot}/%{install_libdir} %{__ninja} check-all -C ./_build
%{install_includedir}/llvm-gmock %{install_includedir}/llvm-gmock
%changelog %changelog
* Mon Jul 22 2024 liyunfei <liyunfei33@huawei.com> - 17.0.6-14
- Prevent environment variables from exceeding NAME_MAX.
* Mon Jul 22 2024 liyunfei <liyunfei33@huawei.com> - 17.0.6-13 * Mon Jul 22 2024 liyunfei <liyunfei33@huawei.com> - 17.0.6-13
- Disable toolchain_clang build for BiSheng Autotuner support temporary. - Disable toolchain_clang build for BiSheng Autotuner support temporary.