Browse Source

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 <alberto.escolar.piedras@nordicsemi.no>
pull/92325/merge
Alberto Escolar Piedras 1 week ago committed by Daniel DeGrasse
parent
commit
1deb2e3c68
  1. 8
      subsys/net/lib/http/http_server_http2.c

8
subsys/net/lib/http/http_server_http2.c

@ -261,14 +261,14 @@ int send_settings_frame(struct http_client_ctx *client, bool ack) @@ -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);

Loading…
Cancel
Save