Hi Remi & Baptiste,
Op 7-9-2015 om 12:36 schreef Baptiste:
On Mon, Sep 7, 2015 at 12:32 PM, Remi Gacogne <[email protected]> wrote:
Hi,
On 09/07/2015 10:47 AM, Baptiste wrote:
It fails that way:
socket(PF_INET,SOCK_DGRAM,17) = (0x4)
connect(4,{ AF_INET 8.8.8.8:53 },128) ERR#22 'Invalid argument'
3rd argument for connect() looks wrong for ipv4:
ERRORS
The connect() system call fails if:
[EINVAL] The namelen argument is not a valid length for the
address family.
Ok, excellent.
I wonder how this could happen :)
It looks like this code is passing the size of a struct
sockaddr_storage to connect(), instead of the size corresponding to the
underlying socket family. Some OS are forgiving, other not so much :)
diff --git a/src/dns.c b/src/dns.c
index 4bc5448..f725ff4 100644
--- a/src/dns.c
+++ b/src/dns.c
@@ -819,7 +819,7 @@ int dns_init_resolvers(void)
}
/* "connect" the UDP socket to the name server IP */
- if (connect(fd, (struct
sockaddr*)&curnameserver->addr, sizeof(curnameserver->addr)) == -1) {
+ if (connect(fd, (struct
sockaddr*)&curnameserver->addr, get_addr_len(&curnameserver->addr)) == -1) {
Alert("Starting [%s/%s] nameserver:
can't connect socket.\n", curr_resolvers->id,
curnameserver->id);
close(fd);
Thanks a lot Remi!
Piba, could you please check it works with Remi's feedback?
If yes, I'll send a patch to Willy with the fix.
Baptiste
The fix works.
At least now dns requests are send and 'some' reply comes back. A new
mail following about that..
PiBa-NL