Fix ENet Buffer data/length ordering issue - #7070
Open
raymcveety wants to merge 1 commit into
Open
Conversation
raymcveety
commented
Jul 17, 2026
Comment on lines
62
to
+64
| Buffer :: struct { | ||
| data: rawptr, | ||
| dataLength: uint, | ||
| data: rawptr, |
Author
There was a problem hiding this comment.
This is ultimately passed in as LPWSABUF which is expected to be length first
raymcveety
marked this pull request as ready for review
July 17, 2026 05:46
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Our team discovered this issue when we were trying to send a UDP broadcast packet using enet_socket_send().
On Linux, the broadcast works as expected, but on Windows the function returns -1.
Calling WSAGetLastError() returns a code of WSAEFAULT indicating an error with the pointer parameters.
This lead us to inspect the parameters accepted by enet.socket_send and how they were subsequently transformed/translated into the parameters for WSASendTo where we noticed the ENetBuffer passed in "buffers" as LPWSABUF
Here's essentially what we were passing to socket_send for the buffer:
Currently enet.Buffer is defined in win32.odin with the order (data first):
But LPWSABUF (which is a long pointer to WSABUF) expects the opposite ordering of the data and length (length first):
So the crash was due to the length being interpreted as the data/data being interpreted as length.
The fix is simple (and we verified locally it eliminates the WSAEFAULT) which is to reverse the order of the members of the Buffer struct in win32.odin
We verified the forked compiler builds with these changes, our project builds on the forked compiler, and the WSAEFAULT no longer occurs when we call enet.socket_send using the enet.Buffer struct.