]> granicus.if.org Git - ipset/commitdiff
Avoid possible syntax clashing at saving hostnames
authorJozsef Kadlecsik <kadlec@blackhole.kfki.hu>
Mon, 24 Jan 2011 16:38:26 +0000 (17:38 +0100)
committerJozsef Kadlecsik <kadlec@blackhole.kfki.hu>
Mon, 24 Jan 2011 16:38:26 +0000 (17:38 +0100)
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

index 7ec786f6b8f3528fd99d2c213385bbc56206aaaf..b045d171bec54d87b835632a360f7ee5cc9a7342 100644 (file)
@@ -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,                    \