mirror of
https://github.com/obgm/libcoap.git
synced 2026-11-04 17:02:56 +03:00
coap_session.c: Fix GCC array bounds warning for memcpy
Copying from the multidimensional coap_layers_coap array into the coap_layers of endpoint::sock.lfunc triggers a warning from GCC v13.2.0 as the global variable has no space for the end marker COAP_PROTO_LAST. This change adds an assertion to indicate that proto is always less than COAP_PROTO_LAST.
This commit is contained in:
1 parent
c8a305a6cd
commit
8ca36cdf05
1 file changed
+1
@@ -1756,6 +1756,7 @@ coap_new_endpoint(coap_context_t *context, const coap_address_t *listen_addr, co
|
||||
ep->context = context;
|
||||
ep->proto = proto;
|
||||
ep->sock.endpoint = ep;
|
||||
assert(proto < COAP_PROTO_LAST);
|
||||
memcpy(&ep->sock.lfunc, coap_layers_coap[proto], sizeof(ep->sock.lfunc));
|
||||
|
||||
if (COAP_PROTO_NOT_RELIABLE(proto)) {
|
||||
|
||||
Reference in new issue
Block a user