@@ -1028,8 +1028,7 @@ String SARA_R5::getIMSI(void)
1028
1028
String SARA_R5::getCCID (void )
1029
1029
{
1030
1030
char *response;
1031
- const int maxTextLen = 21 ;
1032
- char ccidResponse[maxTextLen] = {0x00 }; // E.g. +CCID: 8939107900010087330
1031
+ char ccidResponse[21 ] = {0x00 }; // E.g. +CCID: 8939107900010087330
1033
1032
SARA_R5_error_t err;
1034
1033
1035
1034
response = sara_r5_calloc_char (minimumResponseAllocation);
@@ -1043,12 +1042,9 @@ String SARA_R5::getCCID(void)
1043
1042
{
1044
1043
searchPtr += strlen (" \r\n +CCID:" ); // Move searchPtr to first character - probably a space
1045
1044
while (*searchPtr == ' ' ) searchPtr++; // skip spaces
1046
- if (strlen (searchPtr) < maxTextLen) // Check we have enough space to hold the text
1045
+ if (sscanf (searchPtr, " %20s " , ccidResponse) != 1 )
1047
1046
{
1048
- if (sscanf (searchPtr, " %s" , ccidResponse) != 1 )
1049
- {
1050
- ccidResponse[0 ] = 0 ;
1051
- }
1047
+ ccidResponse[0 ] = 0 ;
1052
1048
}
1053
1049
}
1054
1050
}
@@ -1059,8 +1055,7 @@ String SARA_R5::getCCID(void)
1059
1055
String SARA_R5::getSubscriberNo (void )
1060
1056
{
1061
1057
char *response;
1062
- const int maxTextLen = 128 ;
1063
- char idResponse[maxTextLen] = {0x00 }; // E.g. +CNUM: "ABCD . AAA","123456789012",129
1058
+ char idResponse[128 ] = {0x00 }; // E.g. +CNUM: "ABCD . AAA","123456789012",129
1064
1059
SARA_R5_error_t err;
1065
1060
1066
1061
response = sara_r5_calloc_char (minimumResponseAllocation);
@@ -1074,12 +1069,9 @@ String SARA_R5::getSubscriberNo(void)
1074
1069
{
1075
1070
searchPtr += strlen (" \r\n +CNUM:" ); // Move searchPtr to first character - probably a space
1076
1071
while (*searchPtr == ' ' ) searchPtr++; // skip spaces
1077
- if (strlen (searchPtr) < maxTextLen) // Check we have enough space to hold the text
1072
+ if (sscanf (searchPtr, " %127s " , idResponse) != 1 )
1078
1073
{
1079
- if (sscanf (searchPtr, " %s" , idResponse) != 1 )
1080
- {
1081
- idResponse[0 ] = 0 ;
1082
- }
1074
+ idResponse[0 ] = 0 ;
1083
1075
}
1084
1076
}
1085
1077
}
0 commit comments