diff options
author | Jozsef Kadlecsik <kadlec@blackhole.kfki.hu> | 2011-01-24 17:38:26 +0100 |
---|---|---|
committer | Jozsef Kadlecsik <kadlec@blackhole.kfki.hu> | 2011-01-24 17:38:26 +0100 |
commit | 15d91179ef61df920bf5e90bab538cb71f36d0f8 (patch) | |
tree | 648ed10ad90cf24e62de85bf0f0f11faa21c1d2a /lib | |
parent | 174a7deab7f02ab1cd9f041a934a4d9b6a4c675b (diff) |
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.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/print.c | 3 |
1 files changed, 2 insertions, 1 deletions
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, \ |