Merge topic 'tryrun-strcpy'

a483b7ea TryRun: do not call strcpy()

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !1364
This commit is contained in:
Brad King 2017-10-10 13:10:51 +00:00 committed by Kitware Robot
commit 8af7a16be7

View File

@ -4,7 +4,6 @@
#include "cmsys/FStream.hxx"
#include <stdio.h>
#include <string.h>
#include "cmMakefile.h"
#include "cmState.h"
@ -191,13 +190,15 @@ void cmTryRunCommand::RunExecutable(const std::string& runArgs,
finalCommand.c_str(), out, out, &retVal, nullptr,
cmSystemTools::OUTPUT_NONE, timeout);
// set the run var
char retChar[1000];
char retChar[16];
const char* retStr;
if (worked) {
sprintf(retChar, "%i", retVal);
retStr = retChar;
} else {
strcpy(retChar, "FAILED_TO_RUN");
retStr = "FAILED_TO_RUN";
}
this->Makefile->AddCacheDefinition(this->RunResultVariable, retChar,
this->Makefile->AddCacheDefinition(this->RunResultVariable, retStr,
"Result of TRY_RUN",
cmStateEnums::INTERNAL);
}