BUG: make sure null terminator is in the right place for putenv static char array

This commit is contained in:
Bill Hoffman 2004-01-08 09:59:24 -05:00
parent 4f4984ff7f
commit c336a9b1ac
3 changed files with 5 additions and 7 deletions

View File

@ -2820,7 +2820,6 @@ int cmCTest::RunMakeCommand(const char* command, std::string* output,
int cmCTest::RunTest(std::vector<const char*> argv, std::string* output, int *retVal)
{
#if 0
if(cmSystemTools::SameFile(argv[0], m_CTestSelf.c_str()))
{
cmCTest inst;
@ -2840,7 +2839,6 @@ int cmCTest::RunTest(std::vector<const char*> argv, std::string* output, int *re
}
return cmsysProcess_State_Exited;
}
#endif
std::vector<char> tempOutput;
if ( output )
{
@ -3000,7 +2998,7 @@ int cmCTest::RunConfigurationScript()
size = 4999;
}
strncpy(ctestEnvStatic[i], envArgs[i].c_str(), size);
ctestEnvStatic[i][4999] = 0;
ctestEnvStatic[i][size] = 0;
putenv(ctestEnvStatic[i]);
}
}

View File

@ -178,7 +178,7 @@ void cmGlobalGenerator::EnableLanguage(const char* lang,
size = 4999;
}
strncpy(envCXX, env.c_str(), size);
envCXX[4999] = 0;
envCXX[size] = 0;
putenv(envCXX);
}
}

View File

@ -877,7 +877,7 @@ void cmake::SetGlobalGenerator(cmGlobalGenerator *gg)
size = 4999;
}
strncpy(envCC, env.c_str(), size);
envCC[4999] = 0;
envCC[size] = 0;
putenv(envCC);
// Restore CXX
@ -893,7 +893,7 @@ void cmake::SetGlobalGenerator(cmGlobalGenerator *gg)
size = 4999;
}
strncpy(envCXX, env.c_str(), size);
envCXX[4999] = 0;
envCXX[size] = 0;
putenv(envCXX);
}