From 89acaa6775ca3a4aedea510557e6b9c0c01fa5db Mon Sep 17 00:00:00 2001 From: Olaf Bergmann Date: Mon, 9 Sep 2013 13:01:05 +0200 Subject: [PATCH] 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. --- debug.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/debug.c b/debug.c index 5a6b56b4..dcf771f3 100644 --- a/debug.c +++ b/debug.c @@ -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"