summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTom Gundersen <teg@jklm.no>2014-11-01 18:59:55 +0100
committerTom Gundersen <teg@jklm.no>2014-11-01 18:59:55 +0100
commitbab47929613f9e930dd241a01483b37d14b59c69 (patch)
tree0164afc80343fdf3f92f7e21e3e6a68404bc0522 /src
parent4903a73c37d444261c0a6b362e1c27e58100ea72 (diff)
sd-dhcp-lease: use unaligned read helpers
Diffstat (limited to 'src')
-rw-r--r--src/libsystemd-network/sd-dhcp-lease.c11
1 files changed, 3 insertions, 8 deletions
diff --git a/src/libsystemd-network/sd-dhcp-lease.c b/src/libsystemd-network/sd-dhcp-lease.c
index 4fb01c0729..f4979f7da7 100644
--- a/src/libsystemd-network/sd-dhcp-lease.c
+++ b/src/libsystemd-network/sd-dhcp-lease.c
@@ -30,6 +30,7 @@
#include "list.h"
#include "mkdir.h"
#include "fileio.h"
+#include "unaligned.h"
#include "in-addr-util.h"
#include "dhcp-protocol.h"
@@ -205,14 +206,11 @@ sd_dhcp_lease *sd_dhcp_lease_unref(sd_dhcp_lease *lease) {
}
static void lease_parse_u32(const uint8_t *option, size_t len, uint32_t *ret, uint32_t min) {
- be32_t val;
-
assert(option);
assert(ret);
if (len == 4) {
- memcpy(&val, option, 4);
- *ret = be32toh(val);
+ *ret = unaligned_read_be32((be32_t*) option);
if (*ret < min)
*ret = min;
@@ -224,14 +222,11 @@ static void lease_parse_s32(const uint8_t *option, size_t len, int32_t *ret) {
}
static void lease_parse_u16(const uint8_t *option, size_t len, uint16_t *ret, uint16_t min) {
- be16_t val;
-
assert(option);
assert(ret);
if (len == 2) {
- memcpy(&val, option, 2);
- *ret = be16toh(val);
+ *ret = unaligned_read_be16((be16_t*) option);
if (*ret < min)
*ret = min;