mirror of
https://github.com/obgm/libcoap.git
synced 2026-11-06 01:42:53 +03:00
bugfix: off-by-one error in coap_print_addr()
The closing ']' was misplaced, and the pointer not updated correctly. Thanks to Andreas Bender for pointing this out.
This commit is contained in:
1 parent
66012c7bf9
commit
89acaa6775
1 file changed
+2
-2
@@ -201,7 +201,7 @@ coap_print_addr(const struct __coap_address_t *addr, unsigned char *buf, size_t
|
||||
*p++ = hex[(addr->addr.u8[i+1] & 0xf0) >> 4];
|
||||
*p++ = hex[(addr->addr.u8[i+1] & 0x0f)];
|
||||
}
|
||||
*(p-1) = ']';
|
||||
*p++ = ']';
|
||||
# else /* WITH_UIP6 */
|
||||
# warning "IPv4 network addresses will not be included in debug output"
|
||||
|
||||
@@ -217,7 +217,7 @@ coap_print_addr(const struct __coap_address_t *addr, unsigned char *buf, size_t
|
||||
/* @todo manual conversion of port number */
|
||||
#endif /* HAVE_SNPRINTF */
|
||||
|
||||
return buf + len - p;
|
||||
return p - buf;
|
||||
# else /* WITH_CONTIKI */
|
||||
/* TODO: output addresses manually */
|
||||
# warning "inet_ntop() not available, network addresses will not be included in debug output"
|
||||
|
||||
Reference in new issue
Block a user