From 15d91179ef61df920bf5e90bab538cb71f36d0f8 Mon Sep 17 00:00:00 2001 From: Jozsef Kadlecsik Date: Mon, 24 Jan 2011 17:38:26 +0100 Subject: Avoid possible syntax clashing at saving hostnames If resolving is requested and the resolved hostname contains a dash character, print the unresolved IP address instead in order not to clash with the IP/hostname range syntax. --- lib/print.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/print.c b/lib/print.c index 7ec786f..b045d17 100644 --- a/lib/print.c +++ b/lib/print.c @@ -158,7 +158,8 @@ __getnameinfo##f(char *buf, unsigned int len, \ sizeof(saddr), \ buf, len, NULL, 0, flags); \ \ - if (err == EAI_AGAIN && !(flags & NI_NUMERICHOST)) \ + if (!(flags & NI_NUMERICHOST) && \ + (err == EAI_AGAIN || (err == 0 && strchr(buf, '-') != NULL))) \ err = getnameinfo((const struct sockaddr *)&saddr, \ sizeof(saddr), \ buf, len, NULL, 0, \ -- cgit v1.2.3