Skip to content

Commit 7dc48df

Browse files
committed
Change strstr to strnstr
Fixes #12
1 parent 363ec5c commit 7dc48df

File tree

3 files changed

+59
-59
lines changed

3 files changed

+59
-59
lines changed

src/sfe_sara_r5.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ UBX_CELL_error_t SARA_R5::getUtimeMode(UBX_CELL_utime_mode_t *mode, UBX_CELL_uti
3939
if (err == UBX_CELL_ERROR_SUCCESS)
4040
{
4141
int mStore, sStore, scanned = 0;
42-
char *searchPtr = strstr(response, "+UTIME:");
42+
char *searchPtr = strnstr(response, "+UTIME:", minimumResponseAllocation);
4343
if (searchPtr != nullptr)
4444
{
4545
searchPtr += strlen("+UTIME:"); // Move searchPtr to first character - probably a space
@@ -95,7 +95,7 @@ UBX_CELL_error_t SARA_R5::getUtimeIndication(UBX_CELL_utime_urc_configuration_t
9595
if (err == UBX_CELL_ERROR_SUCCESS)
9696
{
9797
int cStore, scanned = 0;
98-
char *searchPtr = strstr(response, "+UTIMEIND:");
98+
char *searchPtr = strnstr(response, "+UTIMEIND:", minimumResponseAllocation);
9999
if (searchPtr != nullptr)
100100
{
101101
searchPtr += strlen("+UTIMEIND:"); // Move searchPtr to first char
@@ -149,7 +149,7 @@ UBX_CELL_error_t SARA_R5::getUtimeConfiguration(int32_t *offsetNanoseconds, int3
149149
if (err == UBX_CELL_ERROR_SUCCESS)
150150
{
151151
int scanned = 0;
152-
char *searchPtr = strstr(response, "+UTIMECFG:");
152+
char *searchPtr = strnstr(response, "+UTIMECFG:", minimumResponseAllocation);
153153
if (searchPtr != nullptr)
154154
{
155155
searchPtr += strlen("+UTIMECFG:"); // Move searchPtr to first char
@@ -263,7 +263,7 @@ UBX_CELL_error_t SARA_R5::getNetworkAssignedIPAddress(int profile, IPAddress *ad
263263

264264
if (err == UBX_CELL_ERROR_SUCCESS)
265265
{
266-
char *searchPtr = strstr(response, "+UPSND:");
266+
char *searchPtr = strnstr(response, "+UPSND:", minimumResponseAllocation);
267267
if (searchPtr != nullptr)
268268
{
269269
searchPtr += strlen("+UPSND:"); // Move searchPtr to first char
@@ -298,7 +298,7 @@ bool SARA_R5::urcHandlerPDPAction(const char *event)
298298
int scanNum;
299299
int remoteIPstore[4];
300300

301-
char *searchPtr = strstr(event, UBX_CELL_MESSAGE_PDP_ACTION_URC);
301+
char *searchPtr = strnstr(event, UBX_CELL_MESSAGE_PDP_ACTION_URC, _RXBuffSize);
302302
if (searchPtr != nullptr)
303303
{
304304
searchPtr += strlen(UBX_CELL_MESSAGE_PDP_ACTION_URC); // Move searchPtr to first character - probably a space

0 commit comments

Comments
 (0)