From 1deb2e3c68befa7377bc56471c915942b041686b Mon Sep 17 00:00:00 2001 From: Alberto Escolar Piedras Date: Tue, 1 Jul 2025 15:43:57 +0200 Subject: [PATCH] net: http_server: Avoid directly accessing address of unaligned struct Use UNALIGNED_MEMBER_ADDR when getting the address of possibly unaligned structures members instead of attempting to directly get the address as an offset. Signed-off-by: Alberto Escolar Piedras --- subsys/net/lib/http/http_server_http2.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/subsys/net/lib/http/http_server_http2.c b/subsys/net/lib/http/http_server_http2.c index fad55b6265e..ef311f17865 100644 --- a/subsys/net/lib/http/http_server_http2.c +++ b/subsys/net/lib/http/http_server_http2.c @@ -261,14 +261,14 @@ int send_settings_frame(struct http_client_ctx *client, bool ack) setting = (struct http2_settings_field *) (settings_frame + HTTP2_FRAME_HEADER_SIZE); UNALIGNED_PUT(htons(HTTP2_SETTINGS_HEADER_TABLE_SIZE), - &setting->id); - UNALIGNED_PUT(0, &setting->value); + UNALIGNED_MEMBER_ADDR(setting, id)); + UNALIGNED_PUT(0, UNALIGNED_MEMBER_ADDR(setting, value)); setting++; UNALIGNED_PUT(htons(HTTP2_SETTINGS_MAX_CONCURRENT_STREAMS), - &setting->id); + UNALIGNED_MEMBER_ADDR(setting, id)); UNALIGNED_PUT(htonl(CONFIG_HTTP_SERVER_MAX_STREAMS), - &setting->value); + UNALIGNED_MEMBER_ADDR(setting, value)); len = HTTP2_FRAME_HEADER_SIZE + 2 * sizeof(struct http2_settings_field);