summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 2928de2)
raw | patch | inline | side by side (parent: 2928de2)
author | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Sun, 3 May 2009 21:45:16 +0000 (23:45 +0200) | ||
committer | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Sun, 3 May 2009 21:45:16 +0000 (23:45 +0200) |
src/ntpd.c | patch | blob | history |
diff --git a/src/ntpd.c b/src/ntpd.c
index 44964bb5a8dbd936d23ef2e828e4d05b2561c543..4bc3139c74c17e12580a811ddc797f7e0d19c332 100644 (file)
--- a/src/ntpd.c
+++ b/src/ntpd.c
if (ptr->v6_flag)
{
- struct sockaddr_in6 *sa_ptr;
- sa_ptr = (struct sockaddr_in6 *) &sa;
+ struct sockaddr_in6 sa6;
- sa_ptr->sin6_family = AF_INET6;
- sa_ptr->sin6_port = htons (123);
- memcpy (&sa_ptr->sin6_addr, &ptr->srcadr6,
+ assert (sizeof (sa) >= sizeof (sa6));
+
+ memset (&sa6, 0, sizeof (sa6));
+ sa6.sin6_family = AF_INET6;
+ sa6.sin6_port = htons (123);
+ memcpy (&sa6.sin6_addr, &ptr->srcadr6,
sizeof (struct in6_addr));
- sa_len = sizeof (struct sockaddr_in6);
+ sa_len = sizeof (sa6);
+
+ memcpy (&sa, &sa6, sizeof (sa6));
}
else
{
- struct sockaddr_in *sa_ptr;
- sa_ptr = (struct sockaddr_in *) &sa;
+ struct sockaddr_in sa4;
- sa_ptr->sin_family = AF_INET;
- sa_ptr->sin_port = htons (123);
- memcpy (&sa_ptr->sin_addr, &ptr->srcadr,
+ assert (sizeof (sa) >= sizeof (sa4));
+
+ memset (&sa4, 0, sizeof (sa4));
+ sa4.sin_family = AF_INET;
+ sa4.sin_port = htons (123);
+ memcpy (&sa4.sin_addr, &ptr->srcadr,
sizeof (struct in_addr));
- sa_len = sizeof (struct sockaddr_in);
+ sa_len = sizeof (sa4);
+
+ memcpy (&sa, &sa4, sizeof (sa4));
}
if (do_reverse_lookups == 0)