Merge pull request #8085 from Icinga/bugfix/not-set-lcnumeric-twice-7563

Fix LC_NUMERIC set twice and use a wrong value
This commit is contained in:
Alexander Aleksandrovič Klimov 2020-10-29 16:47:43 +01:00 committed by GitHub
commit 9c232e942b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 7 deletions

View File

@ -100,23 +100,30 @@ static Value ProcessSpawnImpl(struct msghdr *msgh, const Dictionary::Ptr& reques
envc++;
auto **envp = new char *[envc + (extraEnvironment ? extraEnvironment->GetLength() : 0) + 2];
const char* lcnumeric = "LC_NUMERIC=";
int j = 0;
for (int i = 0; i < envc; i++)
envp[i] = strdup(environ[i]);
for (int i = 0; i < envc; i++) {
if (strncmp(environ[i], lcnumeric, strlen(lcnumeric)) == 0) {
continue;
}
envp[j] = strdup(environ[i]);
++j;
}
if (extraEnvironment) {
ObjectLock olock(extraEnvironment);
int index = envc;
for (const Dictionary::Pair& kv : extraEnvironment) {
String skv = kv.first + "=" + Convert::ToString(kv.second);
envp[index] = strdup(skv.CStr());
index++;
envp[j] = strdup(skv.CStr());
j++;
}
}
envp[envc + (extraEnvironment ? extraEnvironment->GetLength() : 0)] = strdup("LC_NUMERIC=C");
envp[envc + (extraEnvironment ? extraEnvironment->GetLength() : 0) + 1] = nullptr;
envp[j] = strdup("LC_NUMERIC=C");
envp[j + 1] = nullptr;
extraEnvironment.reset();