Skip to content

Commit

Permalink
[c-ares] Fix inverted length check in GrpcPolledFdWindows (grpc#38101)
Browse files Browse the repository at this point in the history
Fix grpc#37969.

There is an inverted length check in GrpcPolledFdWindows before memcpying from gRPC's `recv_from_source_addr_` into c-ares' socket address structure. In newer c-ares version, it changed to use `struct sockaddr_storage` for the socket address which is 128 bytes and hit this issue.

<!--

If you know who should review your pull request, please assign it to that
person, otherwise the pull request would get assigned randomly.

If your pull request is for a specific language, please add the appropriate
lang label.

-->

Closes grpc#38101

COPYBARA_INTEGRATE_REVIEW=grpc#38101 from yijiem:37969 282fc82
PiperOrigin-RevId: 696607100
  • Loading branch information
yijiem authored and copybara-github committed Nov 14, 2024
1 parent 94cbb67 commit e352e89
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ class GrpcPolledFdWindows : public GrpcPolledFd {
// c-ares overloads this recv_from virtual socket function to receive
// data on both UDP and TCP sockets, and from is nullptr for TCP.
if (from != nullptr) {
CHECK(*from_len <= recv_from_source_addr_len_);
CHECK(*from_len >= recv_from_source_addr_len_);
memcpy(from, &recv_from_source_addr_, recv_from_source_addr_len_);
*from_len = recv_from_source_addr_len_;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ class GrpcPolledFdWindows final : public GrpcPolledFd {
// c-ares overloads this recv_from virtual socket function to receive
// data on both UDP and TCP sockets, and from is nullptr for TCP.
if (from != nullptr) {
CHECK(*from_len <= recv_from_source_addr_len_);
CHECK(*from_len >= recv_from_source_addr_len_);
memcpy(from, &recv_from_source_addr_, recv_from_source_addr_len_);
*from_len = recv_from_source_addr_len_;
}
Expand Down

0 comments on commit e352e89

Please sign in to comment.