From c3a165f5e0c576df7bfa0febcdac973ecd23dea7 Mon Sep 17 00:00:00 2001 From: Mark Wooding Date: Sat, 24 May 2014 14:00:03 +0100 Subject: [PATCH] src/addrfam.c (adns_addr2text): Don't print junk in debugging output. At the point we print `adns_addr2text: will print scoped addr ...' the buffer isn't null-terminated. Fortunately, we have the length of the valid portion of the buffer, so use that to print only the good piece. Signed-off-by: Mark Wooding --- src/addrfam.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/addrfam.c b/src/addrfam.c index a357f9e..8a49d5b 100644 --- a/src/addrfam.c +++ b/src/addrfam.c @@ -411,7 +411,8 @@ int adns_addr2text(const struct sockaddr *sa, adns_queryflags flags, assert(remain >= IF_NAMESIZE+1/*%*/); *scopeptr++= '%'; remain--; bool parsedname = 0; - af_debug("will print scoped addr %s %% %"PRIu32"", buffer, scope); + af_debug("will print scoped addr `%.*s' %% %"PRIu32"", + scopeoffset,buffer, scope); if (scope <= UINT_MAX /* so we can pass it to if_indextoname */ && !(flags & adns_qf_addrlit_scope_numeric) && addrtext_scope_use_ifname(sa)) { -- 2.30.2