mirror of
https://github.com/obgm/libcoap.git
synced 2026-11-04 17:02:56 +03:00
coap_debug.c: Fix len parameter for inet_ntop()
On RIOT, inet_ntop() expects the size parameter to reflect the length of the given address. A larger value causes inet_ntop() to return ENOSPC. This change passes the address size as a workaround, or the actual number of remaining bytes in the output buffer in case less than address size bytes remain.
This commit is contained in:
1 parent
a335938f09
commit
32e219a9fc
1 file changed
+2
-1
+2
-1
@@ -196,7 +196,8 @@ coap_print_addr(const struct coap_address_t *addr, unsigned char *buf, size_t le
|
||||
}
|
||||
|
||||
/* Cast needed for Windows, since it doesn't have the correct API signature. */
|
||||
if (inet_ntop(addr->addr.sa.sa_family, addrptr, (char *)p, len) == 0) {
|
||||
if (inet_ntop(addr->addr.sa.sa_family, addrptr, (char *)p,
|
||||
min(len, addr->size)) == 0) {
|
||||
perror("coap_print_addr");
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user