Skip to content

socket: move frame creation after memory check in quic_sendmsg #46

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 5, 2025
Merged

Conversation

lxin
Copy link
Owner

@lxin lxin commented Apr 27, 2025

It is better to create frames only after checking memory availability to avoid freeing a frame if the memory check fails. This patch updates the code accordingly for both handshake and datagram message sending.

Since handshake data may be fragmented into multiple messages, it must first use len = 1 to check the wspace and calculate msg_len with wspace considered in quic_frame_crypto_create(), then perform a second wmem check after frame creation with the real msg_len, similar as what it does for stream data.

Meanwhile, duplicate code in quic_frame_crypto_create() is removed.

It is better to create frames only after checking memory availability to
avoid freeing a frame if the memory check fails. This patch updates the
code accordingly for both handshake and datagram message sending.

Since handshake data may be fragmented into multiple messages, it must
first use len = 1 to check the wspace and calculate msg_len with wspace
considered in quic_frame_crypto_create(), then perform a second wmem
check after frame creation with the real msg_len, similar as what it
does for stream data.

Meanwhile, duplicate code in quic_frame_crypto_create() is removed.

Reported-by: Stefan Metzmacher <metze@samba.org>
Signed-off-by: Xin Long <lucien.xin@gmail.com>
@lxin
Copy link
Owner Author

lxin commented Apr 27, 2025

close #39

@lxin lxin merged commit 75d2d28 into main May 5, 2025
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant