Skip to content

Commit 1deb2e3

Browse files
aescolardanieldegrasse
authored andcommitted
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>
1 parent 82658ea commit 1deb2e3

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

subsys/net/lib/http/http_server_http2.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -261,14 +261,14 @@ int send_settings_frame(struct http_client_ctx *client, bool ack)
261261
setting = (struct http2_settings_field *)
262262
(settings_frame + HTTP2_FRAME_HEADER_SIZE);
263263
UNALIGNED_PUT(htons(HTTP2_SETTINGS_HEADER_TABLE_SIZE),
264-
&setting->id);
265-
UNALIGNED_PUT(0, &setting->value);
264+
UNALIGNED_MEMBER_ADDR(setting, id));
265+
UNALIGNED_PUT(0, UNALIGNED_MEMBER_ADDR(setting, value));
266266

267267
setting++;
268268
UNALIGNED_PUT(htons(HTTP2_SETTINGS_MAX_CONCURRENT_STREAMS),
269-
&setting->id);
269+
UNALIGNED_MEMBER_ADDR(setting, id));
270270
UNALIGNED_PUT(htonl(CONFIG_HTTP_SERVER_MAX_STREAMS),
271-
&setting->value);
271+
UNALIGNED_MEMBER_ADDR(setting, value));
272272

273273
len = HTTP2_FRAME_HEADER_SIZE +
274274
2 * sizeof(struct http2_settings_field);

0 commit comments

Comments
 (0)