Refactored all the sprintf to use snprintf instead. (#628)

This commit is contained in:
Steve Karg
2024-04-27 12:41:45 -05:00
committed by GitHub
parent 70c54817fd
commit bb276e2431
46 changed files with 308 additions and 272 deletions
+3 -3
View File
@@ -204,7 +204,7 @@ void Analog_Input_Present_Value_Set(uint32_t object_instance, float value)
bool Analog_Input_Object_Name(
uint32_t object_instance, BACNET_CHARACTER_STRING *object_name)
{
static char text_string[32] = "";
static char text[32] = "";
unsigned int index;
bool status = false;
@@ -215,8 +215,8 @@ bool Analog_Input_Object_Name(
else {
index = Analog_Input_Instance_To_Index(object_instance);
if (index < MAX_ANALOG_INPUTS) {
sprintf(text_string, "ANALOG INPUT %lu", (unsigned long)index);
status = characterstring_init_ansi(object_name, text_string);
snprintf(text, sizeof(text), "ANALOG INPUT %lu", (unsigned long)index);
status = characterstring_init_ansi(object_name, text);
}
}
return status;
+3 -3
View File
@@ -171,16 +171,16 @@ bool Binary_Output_Out_Of_Service(uint32_t object_instance)
bool Binary_Output_Object_Name(
uint32_t object_instance, BACNET_CHARACTER_STRING *object_name)
{
static char text_string[32] = "";
static char text[32] = "";
bool status = false;
if (object_instance == 0)
status = characterstring_init_ansi(object_name, "Led");
else {
if (object_instance < MAX_BINARY_OUTPUTS) {
sprintf(text_string, "BINARY OUTPUT %lu",
snprintf(text, sizeof(text), "BINARY OUTPUT %lu",
(unsigned long)object_instance);
status = characterstring_init_ansi(object_name, text_string);
status = characterstring_init_ansi(object_name, text);
}
}
return status;