Skip to content

Commit 651e4ac

Browse files
rlubosnashif
authored andcommitted
net: lwm2m: Make sure that endpoint string is NULL terminated
In case the endpoint string provided by the application is longer or equal to CLIENT_EP_LEN - 1, the strncpy() function will not add the NULL terminator. As the endpoint buffer is treated as a C-string in other places in the code, make sure it's NULL terminated by adding NULL explicitly at the end of the buffer. Signed-off-by: Robert Lubos <[email protected]>
1 parent f14a955 commit 651e4ac

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

subsys/net/lib/lwm2m/lwm2m_rd_client.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1040,6 +1040,7 @@ void lwm2m_rd_client_start(struct lwm2m_ctx *client_ctx, const char *ep_name,
10401040

10411041
set_sm_state(ENGINE_INIT);
10421042
strncpy(client.ep_name, ep_name, CLIENT_EP_LEN - 1);
1043+
client.ep_name[CLIENT_EP_LEN - 1] = '\0';
10431044
LOG_INF("Start LWM2M Client: %s", log_strdup(client.ep_name));
10441045
}
10451046

0 commit comments

Comments
 (0)