[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[libmicrohttpd] 16/26: daemon.c: fixed possible unaligned access to 'str
From: |
gnunet |
Subject: |
[libmicrohttpd] 16/26: daemon.c: fixed possible unaligned access to 'struct sockaddr_in' |
Date: |
Mon, 25 Apr 2022 15:08:40 +0200 |
This is an automated email from the git hooks/post-receive script.
karlson2k pushed a commit to branch master
in repository libmicrohttpd.
commit a4036e668134d1ad9637534bac1e0cb55d0a2b36
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
AuthorDate: Sat Apr 23 19:10:50 2022 +0300
daemon.c: fixed possible unaligned access to 'struct sockaddr_in'
On some platforms 'struct sockaddr_in' requires increased alignment
compared to ''struct sockaddr'.
---
src/microhttpd/daemon.c | 13 +++++++------
1 file 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 @@
#include "mhd_itc.h"
#include "mhd_compat.h"
#include "mhd_send.h"
+#include "mhd_align.h"
#if HAVE_SEARCH_H
#include <search.h>
@@ -342,13 +343,13 @@ MHD_ip_addr_to_key (const struct sockaddr *addr,
/* IPv4 addresses */
if (AF_INET == addr->sa_family)
{
- const struct sockaddr_in *addr4 = (const struct sockaddr_in *) addr;
mhd_assert (sizeof (struct sockaddr_in) <= (size_t) addrlen);
key->family = AF_INET;
memcpy (&key->addr.ipv4,
- &addr4->sin_addr,
- sizeof(addr4->sin_addr));
+ ((const uint8_t *) addr)
+ + _MHD_OFFSETOF (struct sockaddr_in, sin_addr),
+ sizeof(((struct sockaddr_in *) NULL)->sin_addr));
return MHD_YES;
}
@@ -356,13 +357,13 @@ MHD_ip_addr_to_key (const struct sockaddr *addr,
/* IPv6 addresses */
if (AF_INET6 == addr->sa_family)
{
- const struct sockaddr_in6 *addr6 = (const struct sockaddr_in6 *) addr;
mhd_assert (sizeof (struct sockaddr_in6) <= (size_t) addrlen);
key->family = AF_INET6;
memcpy (&key->addr.ipv6,
- &addr6->sin6_addr,
- sizeof(addr6->sin6_addr));
+ ((const uint8_t *) addr)
+ + _MHD_OFFSETOF (struct sockaddr_in6, sin6_addr),
+ sizeof(((struct sockaddr_in6 *) NULL)->sin6_addr));
return MHD_YES;
}
#endif
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
- [libmicrohttpd] 11/26: test_shutdown_select: fixed code style, (continued)
- [libmicrohttpd] 11/26: test_shutdown_select: fixed code style, gnunet, 2022/04/25
- [libmicrohttpd] 08/26: configure: changed warning compiler flags, gnunet, 2022/04/25
- [libmicrohttpd] 14/26: doc/examples: improved formatting, gnunet, 2022/04/25
- [libmicrohttpd] 12/26: src/examples: fixed printf format specifiers, gnunet, 2022/04/25
- [libmicrohttpd] 15/26: doc/examples: avoid usage of unportable functions, gnunet, 2022/04/25
- [libmicrohttpd] 09/26: Fixed many macros, gnunet, 2022/04/25
- [libmicrohttpd] 20/26: sha256.c: fixed coding style, gnunet, 2022/04/25
- [libmicrohttpd] 26/26: test_postprocessor: fixed typo, gnunet, 2022/04/25
- [libmicrohttpd] 22/26: sha1.c: fixed coding style, gnunet, 2022/04/25
- [libmicrohttpd] 24/26: MHD_get_daemon_info(): fixed unaligned memory access, gnunet, 2022/04/25
- [libmicrohttpd] 16/26: daemon.c: fixed possible unaligned access to 'struct sockaddr_in',
gnunet <=
- [libmicrohttpd] 23/26: sha1.c: muted alignment warnings, gnunet, 2022/04/25
- [libmicrohttpd] 25/26: Removed unneeded anymore alignment workarounds., gnunet, 2022/04/25
- [libmicrohttpd] 18/26: mhd_bithelpers: minor improvement of internal macros, gnunet, 2022/04/25
- [libmicrohttpd] 17/26: MHD_get_connection_info(): Fixed possible unaligned access, gnunet, 2022/04/25
- [libmicrohttpd] 21/26: sha256.c: muted alignment warnings, gnunet, 2022/04/25