-
Notifications
You must be signed in to change notification settings - Fork 79
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
-Wstringop-truncation warnings observed in core_http_client.c #133
Comments
@SKZahidBasha-Silabs : These warnings can be safely ignored since the target buffer is not necessarily a null terminated string. You can mask these warnings locally with something like:
|
@paulbartell, would be better if we use memcpy instead (since not null terminated) ? |
To help decide on the action to take - the code needs to compile without warnings with the -Wall and -Wextra GCC command line options. |
Is it better to change strncpy() to memcpy() (or) use the pragmas as suggested above. I see memcpy() being used at some places in the same file. |
Better to change the strncpy to memcpy, GCC pragmas are not portable |
@alfred2g / @paulbartell / @RichardBarry so the fix for this would be to convert strncpy to memcpy, is that right? Shall we conclude on the fix approach please? |
@SKZahidBasha-Silabs, yeah that should be the fix, do you want to push a pull request, or you prefer if we do it ? |
@alfred2g I guess you pushing the fix would be nicer for future tracking. Thanks for the confirmation on the approach! |
Code is merged, closing the issue |
Thanks, @alfred2g for fixing this! |
Warnings related to strncpy are observed in the core_http_client.c file at the below lines of code. Attached the warnings snapshot :
Line 1:
( void ) strncpy( pBufferCur,
HTTP_HEADER_FIELD_SEPARATOR,
HTTP_HEADER_FIELD_SEPARATOR_LEN );
Line 2:
( void ) strncpy( pBufferCur,
HTTP_HEADER_END_INDICATOR,
HTTP_HEADER_END_INDICATOR_LEN );
Line 3:
( void ) strncpy( pBufferCur,
HTTP_HEADER_LINE_SEPARATOR,
HTTP_HEADER_LINE_SEPARATOR_LEN );
The text was updated successfully, but these errors were encountered: