set env in ProcessInvoker sanitized (#2280)

* set env in ProcessInvoker sanitized
This commit is contained in:
Stefan Ruvceski
2022-12-19 15:01:53 +01:00
committed by GitHub
parent 04761e5353
commit f1b1532f32
2 changed files with 79 additions and 0 deletions

View File

@@ -264,7 +264,17 @@ namespace GitHub.Runner.Sdk
{
foreach (KeyValuePair<string, string> kvp in environment)
{
#if OS_WINDOWS
string tempKey = String.IsNullOrWhiteSpace(kvp.Key) ? kvp.Key : kvp.Key.Split('\0')[0];
string tempValue = String.IsNullOrWhiteSpace(kvp.Value) ? kvp.Value : kvp.Value.Split('\0')[0];
if(!String.IsNullOrWhiteSpace(tempKey))
{
_proc.StartInfo.Environment[tempKey] = tempValue;
}
#else
_proc.StartInfo.Environment[kvp.Key] = kvp.Value;
#endif
}
}