Bugfix/win32 build warnings (#936)

* Changed win32 port of localtime to use secure OS API functions when compiled with MSVC

* Changed all the sprintf to use snprintf instead in BSC tests to ensure null string endings.
This commit is contained in:
Steve Karg
2025-03-03 10:32:28 -06:00
committed by GitHub
parent b0a26cf2cd
commit 7e725ce028
21 changed files with 317 additions and 275 deletions
+3 -3
View File
@@ -137,9 +137,9 @@ static void ProcessPT(BACNET_PRIVATE_TRANSFER_DATA *data)
decode_character_string(
&data->serviceParameters[iLen], len_value_type, &bsTemp);
/* Only copy as much as we can accept */
strncpy(
(char *)MyData[(int8_t)cBlockNumber].sMyString,
characterstring_value(&bsTemp), MY_MAX_STR);
snprintf(
(char *)MyData[(int8_t)cBlockNumber].sMyString, MY_MAX_STR,
"%s", characterstring_value(&bsTemp));
/* Make sure it is nul terminated */
MyData[(int8_t)cBlockNumber].sMyString[MY_MAX_STR] = '\0';
/* Signal success */
+3 -4
View File
@@ -76,10 +76,9 @@ static void DecodeBlock(char cBlockNum, uint8_t *pData)
}
iLen += decode_character_string(&pData[iLen], len_value_type, &bsName);
strncpy(
(char *)Response.sMyString, characterstring_value(&bsName), MY_MAX_STR);
Response.sMyString[MY_MAX_STR] = '\0'; /* Make sure it is nul terminated */
snprintf(
(char *)Response.sMyString, MY_MAX_STR, "%s",
characterstring_value(&bsName));
printf("Private Transfer Read Block Response\n");
printf("Data Block: %d\n", (int)cBlockNum);
printf(" First Byte : %d\n", (int)Response.cMyByte1);