Skip to content

Conversation

@rlubos
Copy link
Contributor

@rlubos rlubos commented Nov 20, 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 #99678

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>
@rlubos rlubos added the backport v3.7-branch Request backport to the v3.7-branch label Nov 20, 2025
@zephyrbot zephyrbot added area: Networking size: XS A PR changing only a single line of code labels Nov 20, 2025
@sonarqubecloud
Copy link

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

Labels

area: Networking backport v3.7-branch Request backport to the v3.7-branch size: XS A PR changing only a single line of code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Build warnings on subsys/net/lib/websocket/websocket.c

5 participants