From 603ab1d45d0103fc51031152a10ddbdaf7dadf86 Mon Sep 17 00:00:00 2001 From: Jakub Adam Date: Thu, 3 Jan 2019 09:50:25 +0100 Subject: [PATCH] udp-turn: Fix unaligned memory access on ARM --- socket/udp-turn.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/socket/udp-turn.c b/socket/udp-turn.c index bf81fd9c..1bc5e031 100644 --- a/socket/udp-turn.c +++ b/socket/udp-turn.c @@ -362,7 +362,7 @@ socket_recv_messages (NiceSocket *sock, guint f_buffer_len = priv->fragment_buffer->len; for (i = 0; i < n_recv_messages && f_buffer_len >= sizeof (guint16); ++i) { - guint16 msg_len = ntohs (*(guint16 *)f_buffer) + sizeof (guint16); + guint16 msg_len = ((f_buffer[0] << 8) | f_buffer[1]) + sizeof (guint16); if (msg_len > f_buffer_len) { /* The next message in the buffer isn't complete yet. Wait for more @@ -452,7 +452,7 @@ socket_recv_messages (NiceSocket *sock, * return. */ guint16 msg_len = 0; if (!priv->fragment_buffer) { - msg_len = ntohs (*(guint16 *)buffer) + sizeof (guint16); + msg_len = ((buffer[0] << 8) | buffer[1]) + sizeof (guint16); if (msg_len > parsed_buffer_length) { /* The RFC4571 frame is larger than the current TURN message, need to * buffer it and wait for more data. */