Skip to content

Commit 6edbd3a

Browse files
committed
Merge branch 'develop' into feature/MCU8MASS-1842-curl-response-code
2 parents b98d6b1 + 3ad1a13 commit 6edbd3a

File tree

3 files changed

+21
-28
lines changed

3 files changed

+21
-28
lines changed

src/http_client.cpp

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -321,33 +321,27 @@ HttpResponse HttpClientClass::post(const char* endpoint,
321321

322322
switch (content_type) {
323323
case CONTENT_TYPE_APPLICATION_X_WWW_FORM_URLENCODED:
324-
strncpy_P(content_type_buffer,
325-
HTTP_CONTENT_TYPE_APPLICATION_X_WWW_FORM_URLENCODED,
326-
sizeof(content_type_buffer));
324+
strcpy_P(content_type_buffer,
325+
HTTP_CONTENT_TYPE_APPLICATION_X_WWW_FORM_URLENCODED);
327326
break;
328327

329328
case CONTENT_TYPE_APPLICATION_OCTET_STREAM:
330-
strncpy_P(content_type_buffer,
331-
HTTP_CONTENT_TYPE_APPLICATION_OCTET_STREAM,
332-
sizeof(content_type_buffer));
329+
strcpy_P(content_type_buffer,
330+
HTTP_CONTENT_TYPE_APPLICATION_OCTET_STREAM);
333331
break;
334332

335333
case CONTENT_TYPE_MULTIPART_FORM_DATA:
336-
strncpy_P(content_type_buffer,
337-
HTTP_CONTENT_TYPE_APPLICATION_MULTIPART_FORM_DATA,
338-
sizeof(content_type_buffer));
334+
strcpy_P(content_type_buffer,
335+
HTTP_CONTENT_TYPE_APPLICATION_MULTIPART_FORM_DATA);
339336
break;
340337

341338
case CONTENT_TYPE_APPLICATION_JSON:
342-
strncpy_P(content_type_buffer,
343-
HTTP_CONTENT_TYPE_APPLICATION_APPLICATION_JSON,
344-
sizeof(content_type_buffer));
339+
strcpy_P(content_type_buffer,
340+
HTTP_CONTENT_TYPE_APPLICATION_APPLICATION_JSON);
345341
break;
346342

347343
default:
348-
strncpy_P(content_type_buffer,
349-
HTTP_CONTENT_TYPE_TEXT_PLAIN,
350-
sizeof(content_type_buffer));
344+
strcpy_P(content_type_buffer, HTTP_CONTENT_TYPE_TEXT_PLAIN);
351345
break;
352346
}
353347

src/mqtt_client.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,13 @@ static void internalDisconnectCallback(char* urc_data) {
120120

121121
static void internalOnReceiveCallback(char* urc_data) {
122122

123+
// The incoming urc_data is a buffer of maximum URC_DATA_BUFFER_SIZE (from
124+
// the SequansController)
123125
strncpy(urc_buffer, urc_data, URC_DATA_BUFFER_SIZE);
124126

127+
// Safe guard ourselves
128+
urc_buffer[URC_DATA_BUFFER_SIZE] = '\0';
129+
125130
const bool got_topic = SequansController.extractValueFromCommandResponse(
126131
urc_buffer,
127132
1,

src/sequans_controller.cpp

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -903,13 +903,11 @@ bool SequansControllerClass::extractValueFromCommandResponse(
903903
const size_t destination_buffer_size,
904904
const char start_character) {
905905

906-
// We need a copy in order to not modify the original
907-
size_t rcp_size = strlen(response) + 1;
908-
char response_copy[rcp_size];
909-
strncpy(response_copy, response, rcp_size);
910-
911-
// Safe guard ourselves
912-
response_copy[rcp_size - 1] = '\0';
906+
// We need a copy in order to not modify the original. This copy will
907+
// include the null termination.
908+
const size_t response_size = strlen(response) + 1;
909+
char response_copy[response_size] = "";
910+
strcpy(response_copy, response);
913911

914912
char* data;
915913

@@ -1034,13 +1032,9 @@ bool SequansControllerClass::registerCallback(const char* urc_identifier,
10341032
if (urcs[i].identifier_length == 0) {
10351033

10361034
if (is_flash_string) {
1037-
strncpy_P((char*)urcs[i].identifier,
1038-
urc_identifier,
1039-
URC_IDENTIFIER_BUFFER_SIZE);
1035+
strcpy_P((char*)urcs[i].identifier, urc_identifier);
10401036
} else {
1041-
strncpy((char*)urcs[i].identifier,
1042-
urc_identifier,
1043-
URC_IDENTIFIER_BUFFER_SIZE);
1037+
strcpy((char*)urcs[i].identifier, urc_identifier);
10441038
}
10451039

10461040
urcs[i].identifier_length = urc_identifier_length;

0 commit comments

Comments
 (0)