From 3976131e351ceea687da346cb212a579046f4a0f Mon Sep 17 00:00:00 2001 From: Andy Green Date: Wed, 25 Sep 2024 06:37:41 +0100 Subject: [PATCH] unix-sockets: extra care around short for some toolchains https://github.com/warmcat/libwebsockets/issues/3163 --- lib/plat/unix/unix-sockets.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/plat/unix/unix-sockets.c b/lib/plat/unix/unix-sockets.c index aff0a2af6..1a40c9cf9 100644 --- a/lib/plat/unix/unix-sockets.c +++ b/lib/plat/unix/unix-sockets.c @@ -441,7 +441,7 @@ lws_plat_rawudp_broadcast(uint8_t *p, const uint8_t *canned, size_t canned_len, p[3] = (uint8_t)(n); while (p16 < (uint16_t *)(p + 20)) - ucs += ntohs(*p16++); + ucs = ucs + (uint32_t)(ntohs((uint16_t)(*p16++))); ucs += ucs >> 16; ucs ^= 0xffff; @@ -453,7 +453,7 @@ lws_plat_rawudp_broadcast(uint8_t *p, const uint8_t *canned, size_t canned_len, memset(&sll, 0, sizeof(sll)); sll.sll_family = AF_PACKET; - sll.sll_protocol = htons(0x800); + sll.sll_protocol = (uint32_t)(htons((uint16_t)0x800)); sll.sll_halen = 6; sll.sll_ifindex = (int)if_nametoindex(iface); memset(sll.sll_addr, 0xff, 6);