From c44d3917d0aa3d2ce0b25b2f69deab7b2301cbfd Mon Sep 17 00:00:00 2001 From: bert hubert Date: Thu, 7 Jan 2016 13:37:17 +0100 Subject: [PATCH] don't return nonsense when toString() is called on an unset or invalid ComboAddress --- pdns/iputils.hh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pdns/iputils.hh b/pdns/iputils.hh index e15d26a95..50455066b 100644 --- a/pdns/iputils.hh +++ b/pdns/iputils.hh @@ -211,9 +211,10 @@ union ComboAddress { string toString() const { char host[1024]; - getnameinfo((struct sockaddr*) this, getSocklen(), host, sizeof(host),0, 0, NI_NUMERICHOST); - - return host; + if(sin4.sin_family && !getnameinfo((struct sockaddr*) this, getSocklen(), host, sizeof(host),0, 0, NI_NUMERICHOST)) + return host; + else + return "invalid"; } string toStringWithPort() const -- 2.40.0