1 commit 12c53f98e44598b87d3f2308e0d892f49d7af8e4
2 Author: Roger Wolff <R.E.Wolff@BitWizard.nl>
3 Date: Tue Jul 16 13:59:52 2013 +0200
5 Fix bombout with ipv6 enabled binary on ipv4 only system.
7 diff --git a/dns.c b/dns.c
8 index 371934f..221665d 100644
11 @@ -529,10 +529,12 @@ void dns_open(void)
13 resfd6 = socket(AF_INET6, SOCK_DGRAM, 0);
15 + // consider making removing this warning. For now leave it in to see
16 + // new code activated. -- REW
18 "Unable to allocate IPv6 socket for nameserver communication: %s\n",
25 @@ -543,11 +545,13 @@ void dns_open(void)
29 - if (setsockopt(resfd6,SOL_SOCKET,SO_BROADCAST,(char *)&option,sizeof(option))) {
31 - "Unable to setsockopt() on IPv6 nameserver communication socket: %s\n",
35 + if (setsockopt(resfd6,SOL_SOCKET,SO_BROADCAST,(char *)&option,sizeof(option))) {
37 + "Unable to setsockopt() on IPv6 nameserver communication socket: %s\n",
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) */
48 - for (i = 0;i < NSCOUNT6;i++) {
49 - if (!NSSOCKADDR6(i))
51 - if (NSSOCKADDR6(i)->sin6_family == AF_INET6)
52 - (void)sendto(resfd6,buf,r,0,(struct sockaddr *) NSSOCKADDR6(i),
53 - sizeof(struct sockaddr_in6));
55 + for (i = 0;i < NSCOUNT6;i++) {
56 + if (!NSSOCKADDR6(i))
58 + if (NSSOCKADDR6(i)->sin6_family == AF_INET6)
59 + (void)sendto(resfd6,buf,r,0,(struct sockaddr *) NSSOCKADDR6(i),
60 + sizeof(struct sockaddr_in6));
64 for (i = 0;i < myres.nscount;i++)
65 @@ -1327,6 +1333,9 @@ void dns_ack6(void)
67 static char addrstr[INET6_ADDRSTRLEN];
69 + // Probably not necessary. -- REW
70 + if (resfd6 < 0) return;
72 r = recvfrom(resfd6,(byte *)resrecvbuf,MaxPacketsize,0,
75 diff --git a/gtk.c b/gtk.c
76 index d00f769..38ed507 100644
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);
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);
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
96 @@ -80,8 +80,12 @@ void select_loop(void) {
99 dnsfd6 = dns_waitfd6();
100 - FD_SET(dnsfd6, &readfd);
101 - if(dnsfd6 >= maxfd) maxfd = dnsfd6 + 1;
103 + FD_SET(dnsfd6, &readfd);
104 + if(dnsfd6 >= maxfd) maxfd = dnsfd6 + 1;