From: Jozsef Kadlecsik Date: Mon, 24 Jan 2011 16:38:26 +0000 (+0100) Subject: Avoid possible syntax clashing at saving hostnames X-Git-Tag: v6.0~31 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=15d91179ef61df920bf5e90bab538cb71f36d0f8;p=ipset 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. --- 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, \