fix: untrusted input

Do not read an unlimited size of environment variables.

Signed-off-by: Kamil Kopryk <kamil.kopryk@intel.com>
This commit is contained in:
Kamil Kopryk
2025-02-07 13:56:19 +00:00
committed by Compute-Runtime-Automation
parent 7149743162
commit 03b56dc919
6 changed files with 67 additions and 23 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2022-2024 Intel Corporation
* Copyright (C) 2022-2025 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -32,14 +32,12 @@ int64_t getSetting(const char *settingName, int64_t defaultValue) {
}
std::string getSetting(const char *settingName, const std::string &value) {
char *envValue;
std::string keyValue;
keyValue.assign(value);
envValue = IoFunctions::getenvPtr(settingName);
std::string keyValue = value;
char *envValue = IoFunctions::getEnvironmentVariable(settingName);
if (envValue) {
keyValue.assign(envValue);
}
return keyValue;
}