diff options
author | Thorbjørn Lindeijer <bjorn@lindeijer.nl> | 2024-03-13 13:38:33 +0100 |
---|---|---|
committer | Thorbjørn Lindeijer <bjorn@lindeijer.nl> | 2024-03-13 14:46:18 +0000 |
commit | 7a110c36b58478b633a694ba74a1cb17d237c3df (patch) | |
tree | 1f551bd9a8e956e96c9507435d9d69b5f4fd7be3 /src | |
parent | ded13d1ebfd7aa63a3ec9075e72e26b87ad416a0 (diff) | |
download | mana-7a110c36b58478b633a694ba74a1cb17d237c3df.tar.gz mana-7a110c36b58478b633a694ba74a1cb17d237c3df.tar.bz2 mana-7a110c36b58478b633a694ba74a1cb17d237c3df.tar.xz mana-7a110c36b58478b633a694ba74a1cb17d237c3df.zip |
Use snprintf instead of sprintf
Amendment of dd1db3753ecf8a4d782aee1f518759763d8caf87.
Diffstat (limited to 'src')
-rw-r--r-- | src/resources/userpalette.cpp | 4 | ||||
-rw-r--r-- | src/utils/stringutils.cpp | 10 |
2 files changed, 7 insertions, 7 deletions
diff --git a/src/resources/userpalette.cpp b/src/resources/userpalette.cpp index 16a19d19..12e4d5bc 100644 --- a/src/resources/userpalette.cpp +++ b/src/resources/userpalette.cpp @@ -121,7 +121,7 @@ UserPalette::~UserPalette() if (color.grad == STATIC || color.grad == PULSE) { char buffer[20]; - sprintf(buffer, "0x%06x", color.getRGB()); + snprintf(buffer, 20, "0x%06x", color.getRGB()); config.setValue(configName, std::string(buffer)); } } @@ -220,7 +220,7 @@ void UserPalette::addColor(int type, int rgb, Palette::GradientType grad, { const std::string &configName = ColorTypeNames[type]; char buffer[20]; - sprintf(buffer, "0x%06x", rgb); + snprintf(buffer, 20, "0x%06x", rgb); const std::string rgbString = config.getValue(configName, std::string(buffer)); unsigned int rgbValue = 0; diff --git a/src/utils/stringutils.cpp b/src/utils/stringutils.cpp index 32fc3b0c..a1637892 100644 --- a/src/utils/stringutils.cpp +++ b/src/utils/stringutils.cpp @@ -73,11 +73,11 @@ const char *ipToString(int address) { static char asciiIP[16]; - sprintf(asciiIP, "%i.%i.%i.%i", - (unsigned char)(address), - (unsigned char)(address >> 8), - (unsigned char)(address >> 16), - (unsigned char)(address >> 24)); + snprintf(asciiIP, 16, "%i.%i.%i.%i", + (unsigned char)(address), + (unsigned char)(address >> 8), + (unsigned char)(address >> 16), + (unsigned char)(address >> 24)); return asciiIP; } |