summaryrefslogtreecommitdiff
path: root/src/libsystemd-network/sd-dhcp-server.c
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2016-05-28 15:02:05 -0400
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2016-05-28 15:02:05 -0400
commitccf1c70800ef4fd7220599a1f6214ac592d51a3c (patch)
tree9d485acca29642497d82a3c47a5d0d8295befa56 /src/libsystemd-network/sd-dhcp-server.c
parent16690d0e15964b896531dfcc38fd13576745d77d (diff)
parent9ae84244107ff4bf0f49d1c68e6d4eed3be99b6c (diff)
Merge pull request #3360 from glaubitz/master
Fix multiple unaligned accesses in test-dns-packet and sd-dhcp-server.
Diffstat (limited to 'src/libsystemd-network/sd-dhcp-server.c')
-rw-r--r--src/libsystemd-network/sd-dhcp-server.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/libsystemd-network/sd-dhcp-server.c b/src/libsystemd-network/sd-dhcp-server.c
index fb335337c4..a1af5da40f 100644
--- a/src/libsystemd-network/sd-dhcp-server.c
+++ b/src/libsystemd-network/sd-dhcp-server.c
@@ -29,6 +29,7 @@
#include "in-addr-util.h"
#include "siphash24.h"
#include "string-util.h"
+#include "unaligned.h"
#define DHCP_DEFAULT_LEASE_TIME_USEC USEC_PER_HOUR
#define DHCP_MAX_LEASE_TIME_USEC (USEC_PER_HOUR*12)
@@ -604,17 +605,17 @@ static int parse_request(uint8_t code, uint8_t len, const void *option, void *us
switch(code) {
case SD_DHCP_OPTION_IP_ADDRESS_LEASE_TIME:
if (len == 4)
- req->lifetime = be32toh(*(be32_t*)option);
+ req->lifetime = unaligned_read_be32(option);
break;
case SD_DHCP_OPTION_REQUESTED_IP_ADDRESS:
if (len == 4)
- req->requested_ip = *(be32_t*)option;
+ memcpy(&req->requested_ip, option, sizeof(be32_t));
break;
case SD_DHCP_OPTION_SERVER_IDENTIFIER:
if (len == 4)
- req->server_id = *(be32_t*)option;
+ memcpy(&req->server_id, option, sizeof(be32_t));
break;
case SD_DHCP_OPTION_CLIENT_IDENTIFIER:
@@ -633,8 +634,7 @@ static int parse_request(uint8_t code, uint8_t len, const void *option, void *us
break;
case SD_DHCP_OPTION_MAXIMUM_MESSAGE_SIZE:
if (len == 2)
- req->max_optlen = be16toh(*(be16_t*)option) -
- - sizeof(DHCPPacket);
+ req->max_optlen = unaligned_read_be16(option) - sizeof(DHCPPacket);
break;
}