From 7a07f23da7249c19efa88555543205da366c846c Mon Sep 17 00:00:00 2001 From: Jukka Rissanen Date: Fri, 7 Apr 2017 21:57:52 +0300 Subject: [PATCH] net: tcp: Store MSS in tcp header correctly Use UNALIGNED_PUT() to store the MSS value into network packet because the memory location cannot be guaranteed to be properly aligned. Change-Id: I77fd7a70ef45eedb657cac29457b0239b0a1d4c2 Signed-off-by: Jukka Rissanen --- subsys/net/ip/tcp.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/subsys/net/ip/tcp.c b/subsys/net/ip/tcp.c index 83da8182af1..4d3018728ee 100644 --- a/subsys/net/ip/tcp.c +++ b/subsys/net/ip/tcp.c @@ -521,8 +521,9 @@ static void net_tcp_set_syn_opt(struct net_tcp *tcp, uint8_t *options, recv_mss = 0; } - *((uint32_t *)(options + *optionlen)) = - htonl((uint32_t)(recv_mss | NET_TCP_MSS_HEADER)); + UNALIGNED_PUT(htonl((uint32_t)recv_mss | NET_TCP_MSS_HEADER), + (uint32_t *)(options + *optionlen)); + *optionlen += NET_TCP_MSS_SIZE; }