mirror of
https://github.com/obgm/libcoap.git
synced 2026-11-10 10:50:40 +03:00
coap_session.c: minimize buffer space for coap_session_str()
The buffer szSession for storing a textual representation of the session structure has been trimmed down to 2 * (INET6_ADDRSTRLEN + 8) + 24, allowing two IPv6 address references, port numbers, some structuring text and about eight characters for the interface index. Background: coap_print_addr() calls inet_ntop() for address output which on RIOT is mapped to ipv6_addr_to_str(). As the length parameter of ipv6_addr_to_str() is a uint8_t, only the lower eight bits of szSession's size are effectively used. The previous value of 256 then always lead no ENOSPC because 256 & 0xff == 0.
This commit is contained in:
1 parent
f510b86573
commit
cf5f1a09e9
1 file changed
+1
-1
+1
-1
@@ -1187,7 +1187,7 @@ coap_session_get_by_peer(coap_context_t *ctx,
|
||||
}
|
||||
|
||||
const char *coap_session_str(const coap_session_t *session) {
|
||||
static char szSession[256];
|
||||
static char szSession[2 * (INET6_ADDRSTRLEN + 8) + 24];
|
||||
char *p = szSession, *end = szSession + sizeof(szSession);
|
||||
if (coap_print_addr(&session->addr_info.local,
|
||||
(unsigned char*)p, end - p) > 0)
|
||||
|
||||
Reference in new issue
Block a user