Skip to content

Fix EINVAL on sendto() after recvmsg() on FreeBSD 15#126

Open
zhmylove wants to merge 1 commit into
yarrick:masterfrom
zhmylove:fix-freebsd-replies
Open

Fix EINVAL on sendto() after recvmsg() on FreeBSD 15#126
zhmylove wants to merge 1 commit into
yarrick:masterfrom
zhmylove:fix-freebsd-replies

Conversation

@zhmylove

Copy link
Copy Markdown

On FreeBSD 15, sendto() validates that sockaddr_len matches the address family. After recvmsg(), addrlen was still set to sizeof(struct sockaddr_storage) (128 bytes) instead of the actual length (16 for IPv4), causing EINVAL on every DNS reply.

Fix by reading the real sockaddr length from msg.msg_namelen after recvmsg(), guarded by FreeBSD to avoid unnecessary change on other platforms.

On FreeBSD 15, sendto() validates that sockaddr_len matches
the address family. After recvmsg(), addrlen was still set to
sizeof(struct sockaddr_storage) (128 bytes) instead of the
actual length (16 for IPv4), causing EINVAL on every DNS reply.

Fix by reading the real sockaddr length from msg.msg_namelen
after recvmsg(), guarded by __FreeBSD__ to avoid unnecessary
change on other platforms.

Signed-off-by: Sergei Zhmylev <zhmylove@narod.ru>
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