summaryrefslogtreecommitdiffstats
path: root/Source/cmCTest.cxx
diff options
context:
space:
mode:
authorSean McBride <sean@rogue-research.com>2021-10-21 16:35:57 (GMT)
committerSean McBride <sean@rogue-research.com>2021-10-25 22:23:13 (GMT)
commit5ba6e8ac59333aa574d5963332e3ef0f4c4d3514 (patch)
treed796f695e10d5ec20508cb04f4c8b3c2a6c0d742 /Source/cmCTest.cxx
parent0ce50dd78f68b697e1ab29d52d733b87c5bfb67d (diff)
downloadCMake-5ba6e8ac59333aa574d5963332e3ef0f4c4d3514.zip
CMake-5ba6e8ac59333aa574d5963332e3ef0f4c4d3514.tar.gz
CMake-5ba6e8ac59333aa574d5963332e3ef0f4c4d3514.tar.bz2
Source: Replace most calls to sprintf with snprintf
Diffstat (limited to 'Source/cmCTest.cxx')
-rw-r--r--Source/cmCTest.cxx15
1 files changed, 8 insertions, 7 deletions
diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx
index dfd2b6c..647dd87 100644
--- a/Source/cmCTest.cxx
+++ b/Source/cmCTest.cxx
@@ -227,8 +227,8 @@ struct tm* cmCTest::GetNightlyTime(std::string const& str, bool tomorrowtag)
char buf[1024];
// add todays year day and month to the time in str because
// curl_getdate no longer assumes the day is today
- sprintf(buf, "%d%02d%02d %s", lctime->tm_year + 1900, lctime->tm_mon + 1,
- lctime->tm_mday, str.c_str());
+ snprintf(buf, sizeof(buf), "%d%02d%02d %s", lctime->tm_year + 1900,
+ lctime->tm_mon + 1, lctime->tm_mday, str.c_str());
cmCTestLog(this, OUTPUT,
"Determine Nightly Start Time" << std::endl
<< " Specified time: " << str
@@ -543,9 +543,9 @@ int cmCTest::Initialize(const char* binary_dir, cmCTestStartCommand* command)
this->Impl->TomorrowTag);
}
char datestring[100];
- sprintf(datestring, "%04d%02d%02d-%02d%02d", lctime->tm_year + 1900,
- lctime->tm_mon + 1, lctime->tm_mday, lctime->tm_hour,
- lctime->tm_min);
+ snprintf(datestring, sizeof(datestring), "%04d%02d%02d-%02d%02d",
+ lctime->tm_year + 1900, lctime->tm_mon + 1, lctime->tm_mday,
+ lctime->tm_hour, lctime->tm_min);
tag = datestring;
cmsys::ofstream ofs(tagfile.c_str());
if (ofs) {
@@ -2967,8 +2967,9 @@ void cmCTest::SetStopTime(std::string const& time_str)
tzone_offset *= 100;
char buf[1024];
- sprintf(buf, "%d%02d%02d %s %+05i", lctime->tm_year + 1900,
- lctime->tm_mon + 1, lctime->tm_mday, time_str.c_str(), tzone_offset);
+ snprintf(buf, sizeof(buf), "%d%02d%02d %s %+05i", lctime->tm_year + 1900,
+ lctime->tm_mon + 1, lctime->tm_mday, time_str.c_str(),
+ tzone_offset);
time_t stop_time = curl_getdate(buf, &current_time);
if (stop_time == -1) {