--- iputils-s20121011/Makefile.orig 2012-10-15 12:30:47.000000000 +0200 +++ iputils-s20121011/Makefile 2012-10-15 12:31:53.057830727 +0200 @@ -48,7 +48,7 @@ arping: arping.o $(LINK.o) -o $@ $^ $(LIB_SYSFS) $(LIB_CAP) ping: ping.o ping_common.o - $(LINK.o) -o $@ $^ $(LIB_CAP) + $(LINK.o) -o $@ $^ -lidn $(LIB_CAP) ping6: ping6.o ping_common.o $(LINK.o) -o $@ $^ -lresolv -lcrypto $(LIB_CAP) diff -up iputils-s20100418/ping.c.idn iputils-s20100418/ping.c --- iputils-s20100418/ping.c.idn 2010-04-20 16:07:59.038484302 +0200 +++ iputils-s20100418/ping.c 2010-04-20 16:07:59.077485007 +0200 @@ -58,6 +58,9 @@ char copyright[] = * This program has to run SUID to ROOT to access the ICMP socket. */ +#include +#include + #include "ping_common.h" #include @@ -123,6 +126,10 @@ main(int argc, char **argv) char *target, hnamebuf[MAX_HOSTNAMELEN]; char rspace[3 + 4 * NROUTES + 1]; /* record route space */ + char *idn; + int rc = 0; + setlocale(LC_ALL, ""); + icmp_sock = socket(AF_INET, SOCK_RAW, IPPROTO_ICMP); socket_errno = errno; @@ -250,13 +257,27 @@ main(int argc, char **argv) if (argc == 1) options |= F_NUMERIC; } else { - hp = gethostbyname(target); + rc = idna_to_ascii_lz (target, &idn, 0); + if (rc == IDNA_SUCCESS) + hp = gethostbyname (idn); + else { + fprintf(stderr, "ping: IDN encoding of '%s' failed with error code %d\n", target, rc); + exit(2); + } + free(idn); if (!hp) { fprintf(stderr, "ping: unknown host %s\n", target); exit(2); } memcpy(&whereto.sin_addr, hp->h_addr, 4); - strncpy(hnamebuf, hp->h_name, sizeof(hnamebuf) - 1); + rc = idna_to_unicode_lzlz (hp->h_name, &idn, 0); + if (rc == IDNA_SUCCESS) + strncpy(hnamebuf, idn, sizeof(hnamebuf) - 1); + else { + fprintf(stderr, "ping: IDN encoding of '%s' failed with error code %d\n", hp->h_name, rc); + exit(2); + } + free(idn); hnamebuf[sizeof(hnamebuf) - 1] = 0; hostname = hnamebuf; } diff -up iputils-s20100418/ping_common.c.idn iputils-s20100418/ping_common.c --- iputils-s20100418/ping_common.c.idn 2010-04-20 16:07:59.039478452 +0200 +++ iputils-s20100418/ping_common.c 2010-04-20 16:07:59.069478660 +0200 @@ -1,3 +1,5 @@ +#include + #include "ping_common.h" #include #include @@ -98,6 +100,7 @@ static void fill(char *patp) void common_options(int ch) { + setlocale(LC_ALL, "C"); switch(ch) { case 'a': options |= F_AUDIBLE; @@ -242,6 +245,7 @@ void common_options(int ch) default: abort(); } + setlocale(LC_ALL, ""); }