Code

ntpd plugin: Pass a `struct sockaddr' to `getnameinfo', rather than a `struct in_addr'.
authorFlorian Forster <octo@leeloo.lan.home.verplant.org>
Wed, 1 Nov 2006 08:43:35 +0000 (09:43 +0100)
committerFlorian Forster <octo@leeloo.lan.home.verplant.org>
Wed, 1 Nov 2006 08:43:35 +0000 (09:43 +0100)
Thanks to Lubos Stanek for pointing me in the right direction :)

src/ntpd.c

index fc76a2459130619f47219b873b9e551df620201d..d65d1ed9e60c2e42c46bc6b404fe58559b162afa 100644 (file)
@@ -897,8 +897,15 @@ static void ntpd_read (void)
 
                if (ptr->v6_flag)
                {
-                       status = getnameinfo ((const struct sockaddr *) &ptr->srcadr6,
-                                       sizeof (ptr->srcadr6),
+                       struct sockaddr_in6 sa;
+
+                       memset (&sa, 0, sizeof (sa));
+                       sa.sin6_family = AF_INET6;
+                       sa.sin6_port = htons (123);
+                       memcpy (&sa.sin6_addr, &ptr->srcadr6, sizeof (struct in6_addr));
+
+                       status = getnameinfo ((const struct sockaddr *) &sa,
+                                       sizeof (sa),
                                        peername, sizeof (peername),
                                        NULL, 0, 0 /* no flags */);
                        if (status != 0)