diff options
author | Brad King <brad.king@kitware.com> | 2022-06-23 13:31:31 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2022-06-23 13:31:40 (GMT) |
commit | b865fead7562b9abea847f5e7c0f52e34157a3a0 (patch) | |
tree | f35acc6e97b67a97eb271216f68d69a52f07560b /Source | |
parent | 6760180f578c55212a4b4c7e691e7fd369ae36ba (diff) | |
parent | d5694e46233aa7173134fc3952b5f25a7e0b0f58 (diff) | |
download | CMake-b865fead7562b9abea847f5e7c0f52e34157a3a0.zip CMake-b865fead7562b9abea847f5e7c0f52e34157a3a0.tar.gz CMake-b865fead7562b9abea847f5e7c0f52e34157a3a0.tar.bz2 |
Merge topic 'snprintf'
d5694e4623 Source: Replace uses of sprintf with safer snprintf
eccd0b92b6 Source: Tell Git not to check whitespace in third-party curses form code
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !7383
Diffstat (limited to 'Source')
-rw-r--r-- | Source/CursesDialog/cmCursesLongMessageForm.cxx | 2 | ||||
-rw-r--r-- | Source/CursesDialog/form/.gitattributes | 1 | ||||
-rw-r--r-- | Source/CursesDialog/form/fty_int.c | 2 | ||||
-rw-r--r-- | Source/CursesDialog/form/fty_num.c | 2 | ||||
-rw-r--r-- | Source/cmFindPackageCommand.cxx | 8 | ||||
-rw-r--r-- | Source/cmStringCommand.cxx | 3 | ||||
-rw-r--r-- | Source/cmSystemTools.cxx | 2 |
7 files changed, 11 insertions, 9 deletions
diff --git a/Source/CursesDialog/cmCursesLongMessageForm.cxx b/Source/CursesDialog/cmCursesLongMessageForm.cxx index 8a7bb86..73e3f3c 100644 --- a/Source/CursesDialog/cmCursesLongMessageForm.cxx +++ b/Source/CursesDialog/cmCursesLongMessageForm.cxx @@ -84,7 +84,7 @@ void cmCursesLongMessageForm::UpdateStatusBar() for (size_t i = 0; i < sideSpace; i++) { version[i] = ' '; } - sprintf(version + sideSpace, "%s", vertmp); + snprintf(version + sideSpace, sizeof(version) - sideSpace, "%s", vertmp); version[width] = '\0'; char fmt_s[] = "%s"; diff --git a/Source/CursesDialog/form/.gitattributes b/Source/CursesDialog/form/.gitattributes index 12ede74..6dfa627 100644 --- a/Source/CursesDialog/form/.gitattributes +++ b/Source/CursesDialog/form/.gitattributes @@ -1 +1,2 @@ +* -whitespace * -format.clang-format-6.0 diff --git a/Source/CursesDialog/form/fty_int.c b/Source/CursesDialog/form/fty_int.c index 7107fcc..7aeb4b8 100644 --- a/Source/CursesDialog/form/fty_int.c +++ b/Source/CursesDialog/form/fty_int.c @@ -117,7 +117,7 @@ static bool Check_Integer_Field(FIELD * field, const void * argp) { if (val<low || val>high) return FALSE; } - sprintf(buf,"%.*ld",(prec>0?prec:0),val); + snprintf(buf,sizeof(buf),"%.*ld",(prec>0?prec:0),val); set_field_buffer(field,0,buf); return TRUE; } diff --git a/Source/CursesDialog/form/fty_num.c b/Source/CursesDialog/form/fty_num.c index 7809599..4109b6f 100644 --- a/Source/CursesDialog/form/fty_num.c +++ b/Source/CursesDialog/form/fty_num.c @@ -140,7 +140,7 @@ static bool Check_Numeric_Field(FIELD * field, const void * argp) { if (val<low || val>high) return FALSE; } - sprintf(buf,"%.*f",(prec>0?prec:0),val); + snprintf(buf,sizeof(buf),"%.*f",(prec>0?prec:0),val); set_field_buffer(field,0,buf); return TRUE; } diff --git a/Source/cmFindPackageCommand.cxx b/Source/cmFindPackageCommand.cxx index 8c6a0aa..4ad9124 100644 --- a/Source/cmFindPackageCommand.cxx +++ b/Source/cmFindPackageCommand.cxx @@ -822,13 +822,13 @@ void cmFindPackageCommand::SetVersionVariables( char buf[64]; snprintf(buf, sizeof(buf), "%u", major); addDefinition(prefix + "_MAJOR", buf); - sprintf(buf, "%u", minor); + snprintf(buf, sizeof(buf), "%u", minor); addDefinition(prefix + "_MINOR", buf); - sprintf(buf, "%u", patch); + snprintf(buf, sizeof(buf), "%u", patch); addDefinition(prefix + "_PATCH", buf); - sprintf(buf, "%u", tweak); + snprintf(buf, sizeof(buf), "%u", tweak); addDefinition(prefix + "_TWEAK", buf); - sprintf(buf, "%u", count); + snprintf(buf, sizeof(buf), "%u", count); addDefinition(prefix + "_COUNT", buf); } diff --git a/Source/cmStringCommand.cxx b/Source/cmStringCommand.cxx index c3ee695..fe311d1 100644 --- a/Source/cmStringCommand.cxx +++ b/Source/cmStringCommand.cxx @@ -143,7 +143,8 @@ bool HandleHexCommand(std::vector<std::string> const& args, std::string::size_type hexIndex = 0; for (auto const& c : instr) { - sprintf(&output[hexIndex], "%.2x", static_cast<unsigned char>(c) & 0xFF); + snprintf(&output[hexIndex], 3, "%.2x", + static_cast<unsigned char>(c) & 0xFF); hexIndex += 2; } diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index 351386a..55b0df8 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -1218,7 +1218,7 @@ std::string cmSystemTools::ComputeCertificateThumbprint( certContext, CERT_HASH_PROP_ID, hashData, &hashLength)) { for (DWORD i = 0; i < hashLength; i++) { // Convert each byte to hexadecimal - sprintf(pHashPrint, "%02X", hashData[i]); + snprintf(pHashPrint, 3, "%02X", hashData[i]); pHashPrint += 2; } *pHashPrint = '\0'; |