Skip to content

Commit

Permalink
Fix xnetsocket recvfrom never populating the from_addr due to fromlen…
Browse files Browse the repository at this point in the history
… being zero (#1107)

* Fix recvfrom never populating the from_addr due to fromlen being zero

* Mirror other SockAddr length initialization code

* need to update code too
  • Loading branch information
jonathanou authored Oct 15, 2024
1 parent 027569f commit 5f67172
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion generated/nixnetsocket/nixnetsocket_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -772,7 +772,7 @@ namespace nixnetsocket_grpc {

std::string data(size, '\0');
auto from_addr = allocate_output_storage<nxsockaddr, SockAddr>();
nxsocklen_t fromlen {};
auto fromlen = static_cast<nxsocklen_t>(sizeof(from_addr.storage));
auto status = library_->RecvFrom(socket, (char*)data.data(), size, flags, &from_addr, &fromlen);
if (!status_ok(status)) {
return ConvertApiErrorStatusForNxSOCKET(context, status, socket);
Expand Down
3 changes: 2 additions & 1 deletion source/codegen/metadata/nixnetsocket/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -811,7 +811,8 @@
'direction': 'out',
'name': 'fromlen',
'include_in_proto': False,
'type': 'nxsocklen_t'
'type': 'nxsocklen_t',
'hardcoded_value': 'static_cast<nxsocklen_t>(sizeof(from_addr.storage))'
},
],
'returns': 'int32_t'
Expand Down

0 comments on commit 5f67172

Please sign in to comment.