]> git.pld-linux.org Git - packages/mtr.git/blob - mtr-git.patch
4a2db871c9d7ca09e719a00bb3295ebe3e07ddd6
[packages/mtr.git] / mtr-git.patch
1 commit 12c53f98e44598b87d3f2308e0d892f49d7af8e4
2 Author: Roger Wolff <R.E.Wolff@BitWizard.nl>
3 Date:   Tue Jul 16 13:59:52 2013 +0200
4
5     Fix bombout with ipv6 enabled binary on ipv4 only system.
6
7 diff --git a/dns.c b/dns.c
8 index 371934f..221665d 100644
9 --- a/dns.c
10 +++ b/dns.c
11 @@ -529,10 +529,12 @@ void dns_open(void)
12  #ifdef ENABLE_IPV6
13    resfd6 = socket(AF_INET6, SOCK_DGRAM, 0);
14    if (resfd6 == -1) {
15 +    // consider making removing this warning. For now leave it in to see 
16 +    // new code activated. -- REW
17      fprintf(stderr,
18              "Unable to allocate IPv6 socket for nameserver communication: %s\n",
19             strerror(errno));
20 -    exit(-1);
21 +    //    exit(-1);
22    }
23  #endif
24    option = 1;
25 @@ -543,11 +545,13 @@ void dns_open(void)
26      exit(-1);
27    }
28  #ifdef ENABLE_IPV6
29 -  if (setsockopt(resfd6,SOL_SOCKET,SO_BROADCAST,(char *)&option,sizeof(option))) {
30 -    fprintf(stderr,
31 -            "Unable to setsockopt() on IPv6 nameserver communication socket: %s\n",
32 -           strerror(errno));
33 -    exit(-1);
34 +  if (resfd6 > 0) {
35 +    if (setsockopt(resfd6,SOL_SOCKET,SO_BROADCAST,(char *)&option,sizeof(option))) {
36 +      fprintf(stderr,
37 +             "Unable to setsockopt() on IPv6 nameserver communication socket: %s\n",
38 +             strerror(errno));
39 +      exit(-1);
40 +    }
41    }
42  #endif
43    longipstr( "127.0.0.1", &localhost, AF_INET );
44 @@ -933,12 +937,14 @@ void dorequest(char *s,int type,word id)
45    hp = (packetheader *)buf;
46    hp->id = id; /* htons() deliberately left out (redundant) */
47  #ifdef ENABLE_IPV6
48 -  for (i = 0;i < NSCOUNT6;i++) {
49 -    if (!NSSOCKADDR6(i))
50 -      continue;
51 -    if (NSSOCKADDR6(i)->sin6_family == AF_INET6)
52 -      (void)sendto(resfd6,buf,r,0,(struct sockaddr *) NSSOCKADDR6(i),
53 -                  sizeof(struct sockaddr_in6));
54 +  if (resfd6 > 0) {
55 +    for (i = 0;i < NSCOUNT6;i++) {
56 +      if (!NSSOCKADDR6(i))
57 +       continue;
58 +      if (NSSOCKADDR6(i)->sin6_family == AF_INET6)
59 +       (void)sendto(resfd6,buf,r,0,(struct sockaddr *) NSSOCKADDR6(i),
60 +                    sizeof(struct sockaddr_in6));
61 +    }
62    }
63  #endif
64    for (i = 0;i < myres.nscount;i++)
65 @@ -1327,6 +1333,9 @@ void dns_ack6(void)
66    int r,i;
67    static char addrstr[INET6_ADDRSTRLEN];
68  
69 +  // Probably not necessary. -- REW
70 +  if (resfd6 < 0) return; 
71 +
72    r = recvfrom(resfd6,(byte *)resrecvbuf,MaxPacketsize,0,
73                 from, &fromlen);
74    if (r > 0) {
75 diff --git a/gtk.c b/gtk.c
76 index d00f769..38ed507 100644
77 --- a/gtk.c
78 +++ b/gtk.c
79 @@ -615,8 +615,10 @@ void gtk_loop(void)
80    net_iochannel = g_io_channel_unix_new(net_waitfd());
81    g_io_add_watch(net_iochannel, G_IO_IN, gtk_net_data, NULL);
82  #ifdef ENABLE_IPV6
83 -  dns_iochannel = g_io_channel_unix_new(dns_waitfd6());
84 -  g_io_add_watch(dns_iochannel, G_IO_IN, gtk_dns_data6, NULL);
85 +  if (dns_waitfd6() > 0) {
86 +    dns_iochannel = g_io_channel_unix_new(dns_waitfd6());
87 +    g_io_add_watch(dns_iochannel, G_IO_IN, gtk_dns_data6, NULL);
88 +  }
89  #endif
90    dns_iochannel = g_io_channel_unix_new(dns_waitfd());
91    g_io_add_watch(dns_iochannel, G_IO_IN, gtk_dns_data, NULL);
92 diff --git a/select.c b/select.c
93 index 0545d9f..e7c397e 100644
94 --- a/select.c
95 +++ b/select.c
96 @@ -80,8 +80,12 @@ void select_loop(void) {
97  #ifdef ENABLE_IPV6
98      if (dns) {
99        dnsfd6 = dns_waitfd6();
100 -      FD_SET(dnsfd6, &readfd);
101 -      if(dnsfd6 >= maxfd) maxfd = dnsfd6 + 1;
102 +      if (dnsfd6 >= 0) {
103 +        FD_SET(dnsfd6, &readfd);
104 +        if(dnsfd6 >= maxfd) maxfd = dnsfd6 + 1;
105 +      } else {
106 +        dnsfd6 = 0;
107 +      }
108      } else
109        dnsfd6 = 0;
110  #endif
This page took 0.038148 seconds and 2 git commands to generate.