1 diff -up iputils-s20100418/Makefile.idn iputils-s20100418/Makefile
2 --- iputils-s20100418/Makefile.idn 2010-04-20 16:07:59.018479157 +0200
3 +++ iputils-s20100418/Makefile 2010-04-20 16:10:06.389481427 +0200
4 @@ -28,8 +28,13 @@ all: $(TARGETS)
6 tftpd: tftpd.o tftpsubs.o
7 -arping: arping.o -lsysfs
10 ping: ping.o ping_common.o
11 -ping6: ping6.o ping_common.o -lresolv -lcrypto
12 + $(CC) $(CFLAGS) $(LDFLAGS) ping.o ping_common.o -lidn -o ping
14 +ping6: ping6.o ping_common.o
15 + $(CC) $(CFLAGS) $(LDFLAGS) ping6.o ping_common.o -lresolv -lcrypto -o ping6
17 ping.o ping6.o ping_common.o: ping_common.h
18 tftpd.o tftpsubs.o: tftp.h
20 diff -up iputils-s20100418/ping.c.idn iputils-s20100418/ping.c
21 --- iputils-s20100418/ping.c.idn 2010-04-20 16:07:59.038484302 +0200
22 +++ iputils-s20100418/ping.c 2010-04-20 16:07:59.077485007 +0200
23 @@ -58,6 +58,9 @@ char copyright[] =
24 * This program has to run SUID to ROOT to access the ICMP socket.
30 #include "ping_common.h"
32 #include <netinet/ip.h>
33 @@ -123,6 +126,10 @@ main(int argc, char **argv)
34 char *target, hnamebuf[MAX_HOSTNAMELEN];
35 char rspace[3 + 4 * NROUTES + 1]; /* record route space */
39 + setlocale(LC_ALL, "");
41 icmp_sock = socket(AF_INET, SOCK_RAW, IPPROTO_ICMP);
44 @@ -250,13 +257,27 @@ main(int argc, char **argv)
48 - hp = gethostbyname(target);
49 + rc = idna_to_ascii_lz (target, &idn, 0);
50 + if (rc == IDNA_SUCCESS)
51 + hp = gethostbyname (idn);
53 + fprintf(stderr, "ping: IDN encoding of '%s' failed with error code %d\n", target, rc);
58 fprintf(stderr, "ping: unknown host %s\n", target);
61 memcpy(&whereto.sin_addr, hp->h_addr, 4);
62 - strncpy(hnamebuf, hp->h_name, sizeof(hnamebuf) - 1);
63 + rc = idna_to_unicode_lzlz (hp->h_name, &idn, 0);
64 + if (rc == IDNA_SUCCESS)
65 + strncpy(hnamebuf, idn, sizeof(hnamebuf) - 1);
67 + fprintf(stderr, "ping: IDN encoding of '%s' failed with error code %d\n", hp->h_name, rc);
71 hnamebuf[sizeof(hnamebuf) - 1] = 0;
74 diff -up iputils-s20100418/ping_common.c.idn iputils-s20100418/ping_common.c
75 --- iputils-s20100418/ping_common.c.idn 2010-04-20 16:07:59.039478452 +0200
76 +++ iputils-s20100418/ping_common.c 2010-04-20 16:07:59.069478660 +0200
80 #include "ping_common.h"
83 @@ -98,6 +100,7 @@ static void fill(char *patp)
85 void common_options(int ch)
87 + setlocale(LC_ALL, "C");
91 @@ -242,6 +245,7 @@ void common_options(int ch)
95 + setlocale(LC_ALL, "");