Skip to content

Commit fe00fba

Browse files
committed
Update strncpy sizeof's
1 parent 3d25ee9 commit fe00fba

File tree

5 files changed

+7
-7
lines changed

5 files changed

+7
-7
lines changed

Firmware/RTK_Surveyor/Bluetooth.ino

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,9 +149,9 @@ void bluetoothStart()
149149
{
150150
char stateName[11];
151151
if (systemState >= STATE_ROVER_NOT_STARTED && systemState <= STATE_ROVER_RTK_FIX)
152-
strncpy(stateName, "Rover-", 10);
152+
strncpy(stateName, "Rover-", sizeof(stateName) - 1);
153153
else if (systemState >= STATE_BASE_NOT_STARTED && systemState <= STATE_BASE_FIXED_TRANSMITTING)
154-
strncpy(stateName, "Base-", 10);
154+
strncpy(stateName, "Base-", sizeof(stateName) - 1);
155155

156156
snprintf(deviceName, sizeof(deviceName), "%s %s%02X%02X", platformPrefix, stateName, btMACAddress[4], btMACAddress[5]);
157157

Firmware/RTK_Surveyor/Display.ino

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2465,7 +2465,7 @@ void displayMessage(const char* message, uint16_t displayTime)
24652465

24662466
//Count words based on spaces
24672467
uint8_t wordCount = 0;
2468-
strncpy(temp, message, 20); //strtok modifies the message so make copy
2468+
strncpy(temp, message, sizeof(temp) - 1); //strtok modifies the message so make copy
24692469
char * token = strtok(temp, " ");
24702470
while (token != nullptr)
24712471
{
@@ -2480,7 +2480,7 @@ void displayMessage(const char* message, uint16_t displayTime)
24802480

24812481
//drawFrame();
24822482

2483-
strncpy(temp, message, 20);
2483+
strncpy(temp, message, sizeof(temp) - 1);
24842484
token = strtok(temp, " ");
24852485
while (token != nullptr)
24862486
{

Firmware/RTK_Surveyor/NtripClient.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ bool ntripClientConnect()
8888

8989
//Remove any http:// or https:// prefix from host name
9090
char hostname[51];
91-
strncpy(hostname, settings.ntripClient_CasterHost, 50); //strtok modifies string to be parsed so we create a copy
91+
strncpy(hostname, settings.ntripClient_CasterHost, sizeof(hostname) - 1); //strtok modifies string to be parsed so we create a copy
9292
char *token = strtok(hostname, "//");
9393
if (token != nullptr)
9494
{

Firmware/RTK_Surveyor/NtripServer.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ bool ntripServerConnectCaster()
8787

8888
//Remove any http:// or https:// prefix from host name
8989
char hostname[51];
90-
strncpy(hostname, settings.ntripServer_CasterHost, 50); //strtok modifies string to be parsed so we create a copy
90+
strncpy(hostname, settings.ntripServer_CasterHost, sizeof(hostname) - 1); //strtok modifies string to be parsed so we create a copy
9191
char *token = strtok(hostname, "//");
9292
if (token != nullptr)
9393
{

Firmware/RTK_Surveyor/menuGNSS.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ void menuGNSS()
217217
//Error check for RTK2Go without email in user name
218218
//First force tolower the host name
219219
char lowerHost[51];
220-
strncpy(lowerHost, settings.ntripClient_CasterHost, 50);
220+
strncpy(lowerHost, settings.ntripClient_CasterHost, sizeof(lowerHost) - 1);
221221
for (int x = 0 ; x < 50 ; x++)
222222
{
223223
if (lowerHost[x] == '\0') break;

0 commit comments

Comments
 (0)