From 7a110c36b58478b633a694ba74a1cb17d237c3df Mon Sep 17 00:00:00 2001 From: Thorbjørn Lindeijer Date: Wed, 13 Mar 2024 13:38:33 +0100 Subject: Use snprintf instead of sprintf Amendment of dd1db3753ecf8a4d782aee1f518759763d8caf87. --- src/resources/userpalette.cpp | 4 ++-- 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; } -- cgit v1.2.3-70-g09d2