f86a533db1
- fix for #68212, previous fix actually didn't work for ping6 - renewed the ia64 align patches - update README.bonding - clear up the code from warnings - spec file cleanup
131 lines
3.3 KiB
Diff
131 lines
3.3 KiB
Diff
--- iputils-s20070202/ping.c.idn 2007-08-06 14:45:36.000000000 +0200
|
|
+++ iputils-s20070202/ping.c 2007-08-06 14:45:36.000000000 +0200
|
|
@@ -58,6 +58,9 @@
|
|
* This program has to run SUID to ROOT to access the ICMP socket.
|
|
*/
|
|
|
|
+#include <idna.h>
|
|
+#include <locale.h>
|
|
+
|
|
#include "ping_common.h"
|
|
|
|
#include <netinet/ip.h>
|
|
@@ -122,6 +128,10 @@
|
|
char *target, hnamebuf[MAXHOSTNAMELEN];
|
|
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;
|
|
|
|
@@ -242,13 +254,27 @@
|
|
if (argc == 1)
|
|
options |= F_NUMERIC;
|
|
} else {
|
|
+ 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);
|
|
- hp = gethostbyname(target);
|
|
if (!hp) {
|
|
fprintf(stderr, "ping: unknown host %s\n", target);
|
|
exit(2);
|
|
}
|
|
memcpy(&whereto.sin_addr, hp->h_addr, 4);
|
|
+ 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);
|
|
- strncpy(hnamebuf, hp->h_name, sizeof(hnamebuf) - 1);
|
|
hnamebuf[sizeof(hnamebuf) - 1] = 0;
|
|
hostname = hnamebuf;
|
|
}
|
|
--- iputils-s20070202/Makefile.idn 2007-08-06 14:45:36.000000000 +0200
|
|
+++ iputils-s20070202/Makefile 2007-08-06 14:45:36.000000000 +0200
|
|
@@ -27,8 +27,13 @@
|
|
|
|
|
|
tftpd: tftpd.o tftpsubs.o
|
|
+
|
|
ping: ping.o ping_common.o
|
|
+ $(CC) $(CFLAGS) ping.o ping_common.o -lidn -o ping
|
|
+
|
|
ping6: ping6.o ping_common.o
|
|
+ $(CC) $(CFLAGS) ping6.o ping_common.o -o ping6
|
|
+
|
|
ping.o ping6.o ping_common.o: ping_common.h
|
|
tftpd.o tftpsubs.o: tftp.h
|
|
|
|
--- iputils-s20070202/ping6.c.idn 2007-08-06 14:45:36.000000000 +0200
|
|
+++ iputils-s20070202/ping6.c 2007-08-06 14:45:36.000000000 +0200
|
|
@@ -66,6 +66,9 @@
|
|
* More statistics could always be gathered.
|
|
* This program has to run SUID to ROOT to access the ICMP socket.
|
|
*/
|
|
+#define _GNU_SOURCE
|
|
+#include <locale.h>
|
|
+
|
|
#include "ping_common.h"
|
|
|
|
#include <linux/filter.h>
|
|
@@ -210,6 +216,8 @@
|
|
int err, csum_offset, sz_opt;
|
|
static uint32_t scope_id = 0;
|
|
|
|
+ setlocale(LC_ALL, "");
|
|
+
|
|
icmp_sock = socket(AF_INET6, SOCK_RAW, IPPROTO_ICMPV6);
|
|
socket_errno = errno;
|
|
|
|
@@ -296,6 +306,7 @@
|
|
|
|
memset(&hints, 0, sizeof(hints));
|
|
hints.ai_family = AF_INET6;
|
|
+ hints.ai_flags = AI_IDN;
|
|
gai = getaddrinfo(target, NULL, &hints, &ai);
|
|
if (gai) {
|
|
fprintf(stderr, "unknown host\n");
|
|
@@ -328,6 +341,7 @@
|
|
|
|
memset(&hints, 0, sizeof(hints));
|
|
hints.ai_family = AF_INET6;
|
|
+ hints.ai_flags = AI_IDN;
|
|
gai = getaddrinfo(target, NULL, &hints, &ai);
|
|
if (gai) {
|
|
fprintf(stderr, "unknown host\n");
|
|
--- iputils-s20070202/ping_common.c.idn 2007-08-06 14:45:36.000000000 +0200
|
|
+++ iputils-s20070202/ping_common.c 2007-08-06 14:47:41.000000000 +0200
|
|
@@ -1,3 +1,5 @@
|
|
+#include <locale.h>
|
|
+
|
|
#include "ping_common.h"
|
|
#include <ctype.h>
|
|
#include <sched.h>
|
|
@@ -97,6 +102,7 @@
|
|
|
|
void common_options(int ch)
|
|
{
|
|
+ setlocale(LC_ALL, "C");
|
|
switch(ch) {
|
|
case 'a':
|
|
options |= F_AUDIBLE;
|
|
@@ -222,6 +230,7 @@
|
|
default:
|
|
abort();
|
|
}
|
|
+ setlocale(LC_ALL, "");
|
|
}
|
|
|
|
|