This is the mail archive of the libc-alpha@sourceware.cygnus.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

most buggy function in glibc 8)


Hi,

more problems with getaddrinfo (glibc-2.1.2 with patched getaddrinfo
- patch from glibc cvs but without fix for AAAA only hosts).

I call from postfix (MTA agent):
getaddrinfo("test.misiek.eu.org", .....);

where:
[root@dark /root]# host -a test.misiek.eu.org
Trying null domain
rcode = 0 (Success), ancount=1
The following answer is not verified as authentic by the server:
test.misiek.eu.org      86400 IN        A       12.12.12.12
For authoritative answers, see:
misiek.eu.org   86400 IN        NS      dark.misiek.eu.org
Additional information:
dark.misiek.eu.org      86400 IN        A       192.168.0.1
dark.misiek.eu.org      86400 IN        AAAA    3ffe:902:12::10
[root@dark /root]#
(dns configured on my home computer so isn't available in internet 8)

and getaddrinfo() return 0 and addrinfo structs but badly
filled. For example for AF_INET: sin.sin_family = AF_INET (ok)
sin.sin_addr = 0 (wrong)

This causes that my postfix connects to 0.0.0.0 instead of remote
host (in this case test.misiek.eu.org). When I start nscd then
everything works fine - strange.

I tried to debug getaddrinfo:

I'm in line:
	struct sockaddr_in *sinp =
			  (struct sockaddr_in *) (*pai)->ai_addr;
(xxgdb) print at2
$4 = (struct gaih_addrtuple *) 0xbffff5c4
(xxgdb) print *at2
$5 = {
  next = 0x0, 
  family = 2, 
  addr = "\000\000\000\000\006\000\000\000:\000\000\000\026\000\000"
}
(xxgdb)

and after memset (sinp->sin_zero, '\0', sizeof (sinp->sin_zero)); 
I checked sinp->sin_addr:
(xxgdb) print sinp
$11 = (struct sockaddr_in *) 0x80696c8
(xxgdb) print sinp->sin_addr
$12 = {
  s_addr = 0
}
(xxgdb) 

now with nscd running:
(xxgdb) print *at2
$10 = {
  next = 0x0, 
  family = 2, 
  addr = "\f\f\f\fÄí˙ż\000\004\000\000\024ö˙ż"
}
(xxgdb) 
...
(xxgdb) print sinp
$11 = (struct sockaddr_in *) 0x8068400
(xxgdb) print *sinp
$12 = {
  sin_family = 2, 
  sin_port = 0, 
  sin_addr = {
    s_addr = 202116108
  }, 
  sin_zero = "\000\000\000\000\000\000\000"
}
(xxgdb) 

(from my small resolving program (www.misiek.eu.org/ipv6/host-all.c.gz)
Resolving ... 202116108
fqdn: unknown   ip addr: 12.12.12.12
so it's ok)

and this time I get IPv6 address (IPv4-mapped) of
my host and proper native IPv4 address:
(xxgdb) print *res0->ai_next->ai_addr
$17 = {
  sa_family = 2, 
  sa_data = "\000\000\f\f\f\f\000\000\000\000\000\000\000"
}
(xxgdb) 


Also:
(xxgdb) sizeof(struct in_addr)
$8 = 4
(xxgdb) print sizeof(sinp->sin_addr)
$9 = 4
(xxgdb) print at2->addr
$10 = "\000\000\000\000'\000\000\000\021\000\000\000\027\000\000"
(xxgdb) print sizeof(at2->addr)
$11 = 16
(xxgdb)  print sinp->sin_addr
$6 = {
  s_addr = 0
}
(xxgdb) 

So for me seems that memcpy() doesn't copy proper data:
memcpy (&sinp->sin_addr, at2->addr, sizeof (struct in_addr));

That same problem is on my friend machine with glibc-2.1.2
with full getaddrinfo patch (from glibc cvs).

Moreover resolving "test.misiek.eu.org" works fine in
for example host-all.c but not in my postfix ;-(

struct addrinfo hints, *res0, *res;
memset(&hints, 0, sizeof(hints));
hints.ai_family = PF_UNSPEC;
hints.ai_socktype = SOCK_STREAM;
error = getaddrinfo(host, NULL, &hints, &res0);
if (error)
	...
for (res = res0; res; res = res->ai_next)
itd. Full patch at www.misiek.eu.org/ipv6/

Thanks for help.

ps. I will be very busy in next two week, so ....

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]