Skip to content

Conversation

@rlubos
Copy link
Contributor

@rlubos rlubos commented Dec 9, 2025

WS_MAGIC is a constant string and when calculating lengths for copying we always exclude the NULL terminator. In result, using strncpy() for copying can generate a warning about truncated string, as WS_MAGIC will always be truncated from the NULL terminator. Therefore replace strncpy() with memcpy() as it seems more appropriate for this case.

Fixes #100713

WS_MAGIC is a constant string and when calculating lengths for copying
we always exclude the NULL terminator. In result, using strncpy() for
copying can generate a warning about truncated string, as WS_MAGIC will
always be truncated from the NULL terminator. Therefore replace
strncpy() with memcpy() as it seems more appropriate for this case.

Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
@zephyrbot zephyrbot added area: HTTP HTTP client/server support size: XS A PR changing only a single line of code area: Networking labels Dec 9, 2025
@sonarqubecloud
Copy link

sonarqubecloud bot commented Dec 9, 2025

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: HTTP HTTP client/server support area: Networking size: XS A PR changing only a single line of code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

strncpy warning in websocket code

4 participants