Skip to content

Commit d3c7cb3

Browse files
authored
Code: Replace strncpy with memcpy to remove warnings (#134)
* Code: Replace strncpy with memcpy when the string is not neessarily ending with 0 * Style: fix formatting errors
1 parent 4997be7 commit d3c7cb3

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

source/core_http_client.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1357,9 +1357,9 @@ static HTTPStatus_t addHeader( HTTPRequestHeaders_t * pRequestHeaders,
13571357
pBufferCur += fieldLen;
13581358

13591359
/* Copy the field separator, ": ", into the buffer. */
1360-
( void ) strncpy( pBufferCur,
1361-
HTTP_HEADER_FIELD_SEPARATOR,
1362-
HTTP_HEADER_FIELD_SEPARATOR_LEN );
1360+
( void ) memcpy( pBufferCur,
1361+
HTTP_HEADER_FIELD_SEPARATOR,
1362+
HTTP_HEADER_FIELD_SEPARATOR_LEN );
13631363

13641364
pBufferCur += HTTP_HEADER_FIELD_SEPARATOR_LEN;
13651365

@@ -1375,9 +1375,9 @@ static HTTPStatus_t addHeader( HTTPRequestHeaders_t * pRequestHeaders,
13751375
pBufferCur += valueLen;
13761376

13771377
/* Copy the header end indicator, "\r\n\r\n" into the buffer. */
1378-
( void ) strncpy( pBufferCur,
1379-
HTTP_HEADER_END_INDICATOR,
1380-
HTTP_HEADER_END_INDICATOR_LEN );
1378+
( void ) memcpy( pBufferCur,
1379+
HTTP_HEADER_END_INDICATOR,
1380+
HTTP_HEADER_END_INDICATOR_LEN );
13811381

13821382
/* Update the headers length value only when everything is successful. */
13831383
pRequestHeaders->headersLen = backtrackHeaderLen + toAddLen;
@@ -1524,9 +1524,9 @@ static HTTPStatus_t writeRequestLine( HTTPRequestHeaders_t * pRequestHeaders,
15241524
HTTP_PROTOCOL_VERSION_LEN );
15251525
pBufferCur += HTTP_PROTOCOL_VERSION_LEN;
15261526

1527-
( void ) strncpy( pBufferCur,
1528-
HTTP_HEADER_LINE_SEPARATOR,
1529-
HTTP_HEADER_LINE_SEPARATOR_LEN );
1527+
( void ) memcpy( pBufferCur,
1528+
HTTP_HEADER_LINE_SEPARATOR,
1529+
HTTP_HEADER_LINE_SEPARATOR_LEN );
15301530
pRequestHeaders->headersLen = toAddLen;
15311531
}
15321532

0 commit comments

Comments
 (0)