mirror of
https://github.com/Kitware/CMake.git
synced 2026-05-22 15:58:41 -05:00
Source: Replace uses of sprintf with safer snprintf in CMake 3.24 branch
Backport commit d5694e4623 (Source: Replace uses of sprintf with safer
snprintf, 2022-06-17, v3.25.0-rc1~587^2) to the CMake 3.24 branch. This
is needed to compile without warnings using Xcode 14.1's macOS 13.0 SDK.
This commit is contained in:
@@ -75,10 +75,10 @@ static int CCONV InitialPass(void* inf, void* mf, int argc, char* argv[])
|
||||
info->CAPI->DisplaySatus(mf, info->CAPI->GetStartOutputDirectory(mf));
|
||||
info->CAPI->DisplaySatus(mf, info->CAPI->GetCurrentDirectory(mf));
|
||||
info->CAPI->DisplaySatus(mf, info->CAPI->GetCurrentOutputDirectory(mf));
|
||||
sprintf(buffer, "Cache version: %d.%d, CMake version: %d.%d",
|
||||
info->CAPI->GetCacheMajorVersion(mf),
|
||||
info->CAPI->GetCacheMinorVersion(mf),
|
||||
info->CAPI->GetMajorVersion(mf), info->CAPI->GetMinorVersion(mf));
|
||||
snprintf(
|
||||
buffer, sizeof(buffer), "Cache version: %d.%d, CMake version: %d.%d",
|
||||
info->CAPI->GetCacheMajorVersion(mf), info->CAPI->GetCacheMinorVersion(mf),
|
||||
info->CAPI->GetMajorVersion(mf), info->CAPI->GetMinorVersion(mf));
|
||||
info->CAPI->DisplaySatus(mf, buffer);
|
||||
if (info->CAPI->CommandExists(mf, "SET")) {
|
||||
info->CAPI->DisplaySatus(mf, "Command SET exists");
|
||||
@@ -91,10 +91,12 @@ static int CCONV InitialPass(void* inf, void* mf, int argc, char* argv[])
|
||||
|
||||
source_file = info->CAPI->CreateNewSourceFile(mf);
|
||||
cstr = info->CAPI->SourceFileGetSourceName(source_file);
|
||||
sprintf(buffer, "Should be empty (source file name): [%s]", cstr);
|
||||
snprintf(buffer, sizeof(buffer), "Should be empty (source file name): [%s]",
|
||||
cstr);
|
||||
info->CAPI->DisplaySatus(mf, buffer);
|
||||
cstr = info->CAPI->SourceFileGetFullPath(source_file);
|
||||
sprintf(buffer, "Should be empty (source file full path): [%s]", cstr);
|
||||
snprintf(buffer, sizeof(buffer),
|
||||
"Should be empty (source file full path): [%s]", cstr);
|
||||
info->CAPI->DisplaySatus(mf, buffer);
|
||||
info->CAPI->DefineSourceFileProperty(mf, "SOME_PROPERTY", "unused old prop",
|
||||
"This property is no longer used", 0);
|
||||
@@ -106,7 +108,8 @@ static int CCONV InitialPass(void* inf, void* mf, int argc, char* argv[])
|
||||
"This property is for testing.", 0);
|
||||
info->CAPI->SourceFileSetProperty(source_file, "SOME_PROPERTY2", "HERE");
|
||||
cstr = info->CAPI->SourceFileGetProperty(source_file, "ABSTRACT");
|
||||
sprintf(buffer, "Should be 0 (source file abstract property): [%p]", cstr);
|
||||
snprintf(buffer, sizeof(buffer),
|
||||
"Should be 0 (source file abstract property): [%p]", cstr);
|
||||
info->CAPI->DisplaySatus(mf, buffer);
|
||||
|
||||
info->CAPI->DestroySourceFile(source_file);
|
||||
|
||||
Reference in New Issue
Block a user