From 3a30c63eff874f88d442ec50562b887f81784569 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrien=20Gallou=C3=ABt?= Date: Sat, 28 Dec 2019 11:57:00 +0000 Subject: [PATCH] God doesn't care about endianness MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Adrien Gallouët --- mud.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/mud.c b/mud.c index 4f30f9c..4d3535a 100644 --- a/mud.c +++ b/mud.c @@ -352,7 +352,7 @@ mud_unmapv4(struct sockaddr_storage *addr) } static struct mud_path * -mud_select_path(struct mud *mud, unsigned cursor) +mud_select_path(struct mud *mud, uint16_t cursor) { uint64_t k = (cursor * mud->rate) >> 16; @@ -1545,9 +1545,8 @@ mud_send(struct mud *mud, const void *data, size_t size) return -1; } - const unsigned a = packet[packet_size - 1]; - const unsigned b = packet[packet_size - 2]; - const unsigned k = (a << 8) | b; + uint16_t k; + memcpy(&k, &packet[packet_size - sizeof(k)], sizeof(k)); return mud_send_path(mud, mud_select_path(mud, k), now, packet, (size_t)packet_size, 0);