diff options
Diffstat (limited to 'src/microhttpd/daemon.c')
-rw-r--r-- | src/microhttpd/daemon.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c index 17cf8393..6cbd9ad5 100644 --- a/src/microhttpd/daemon.c +++ b/src/microhttpd/daemon.c | |||
@@ -44,6 +44,7 @@ | |||
44 | #include "mhd_itc.h" | 44 | #include "mhd_itc.h" |
45 | #include "mhd_compat.h" | 45 | #include "mhd_compat.h" |
46 | #include "mhd_send.h" | 46 | #include "mhd_send.h" |
47 | #include "mhd_align.h" | ||
47 | 48 | ||
48 | #if HAVE_SEARCH_H | 49 | #if HAVE_SEARCH_H |
49 | #include <search.h> | 50 | #include <search.h> |
@@ -342,13 +343,13 @@ MHD_ip_addr_to_key (const struct sockaddr *addr, | |||
342 | /* IPv4 addresses */ | 343 | /* IPv4 addresses */ |
343 | if (AF_INET == addr->sa_family) | 344 | if (AF_INET == addr->sa_family) |
344 | { | 345 | { |
345 | const struct sockaddr_in *addr4 = (const struct sockaddr_in *) addr; | ||
346 | mhd_assert (sizeof (struct sockaddr_in) <= (size_t) addrlen); | 346 | mhd_assert (sizeof (struct sockaddr_in) <= (size_t) addrlen); |
347 | 347 | ||
348 | key->family = AF_INET; | 348 | key->family = AF_INET; |
349 | memcpy (&key->addr.ipv4, | 349 | memcpy (&key->addr.ipv4, |
350 | &addr4->sin_addr, | 350 | ((const uint8_t *) addr) |
351 | sizeof(addr4->sin_addr)); | 351 | + _MHD_OFFSETOF (struct sockaddr_in, sin_addr), |
352 | sizeof(((struct sockaddr_in *) NULL)->sin_addr)); | ||
352 | return MHD_YES; | 353 | return MHD_YES; |
353 | } | 354 | } |
354 | 355 | ||
@@ -356,13 +357,13 @@ MHD_ip_addr_to_key (const struct sockaddr *addr, | |||
356 | /* IPv6 addresses */ | 357 | /* IPv6 addresses */ |
357 | if (AF_INET6 == addr->sa_family) | 358 | if (AF_INET6 == addr->sa_family) |
358 | { | 359 | { |
359 | const struct sockaddr_in6 *addr6 = (const struct sockaddr_in6 *) addr; | ||
360 | mhd_assert (sizeof (struct sockaddr_in6) <= (size_t) addrlen); | 360 | mhd_assert (sizeof (struct sockaddr_in6) <= (size_t) addrlen); |
361 | 361 | ||
362 | key->family = AF_INET6; | 362 | key->family = AF_INET6; |
363 | memcpy (&key->addr.ipv6, | 363 | memcpy (&key->addr.ipv6, |
364 | &addr6->sin6_addr, | 364 | ((const uint8_t *) addr) |
365 | sizeof(addr6->sin6_addr)); | 365 | + _MHD_OFFSETOF (struct sockaddr_in6, sin6_addr), |
366 | sizeof(((struct sockaddr_in6 *) NULL)->sin6_addr)); | ||
366 | return MHD_YES; | 367 | return MHD_YES; |
367 | } | 368 | } |
368 | #endif | 369 | #endif |