Repository navigation
Commit 7c35b7d
Guard against empty remote address on macOS accept (dotnet#131869)
Fixes dotnet#121848
## Problem
On macOS, when a peer connects to an `AF_INET6` listening socket and
immediately resets the connection (`SO_LINGER=0`), `accept(2)` returns a
valid file descriptor but leaves the remote sockaddr buffer untouched
and reports `addrlen=0`. This kernel behavior was measured with a plain
C repro in the [issue
comment](dotnet#121848 (comment))
and does not depend on dual-mode or `IPV6_V6ONLY`.
The 2024 fix (dotnet#108616) guarded the `EndPoint.Create` call inside
`FinishOperationAccept` on the Unix path, but the shared
`FinishOperationSyncSuccess` in
[`SocketAsyncEventArgs.cs`](https://github.com/dotnet/runtime/blob/main/src/libraries/System.Net.Sockets/src/System/Net/Sockets/SocketAsyncEventArgs.cs#L1016)
calls `Create` a second time on the same zero-sized `SocketAddress` and
throws `ArgumentException`. For Kestrel this kills the accept loop
permanently while the process stays alive and the port stays bound.
---------
Co-authored-by: Copilot <[email protected]>1 parent ef97877 commit 7c35b7d
3 files changed
Lines changed: 61 additions & 4 deletions
File tree
- src/libraries/System.Net.Sockets
- src/System/Net/Sockets
- tests/FunctionalTests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1089 | 1089 | | |
1090 | 1090 | | |
1091 | 1091 | | |
1092 | | - | |
1093 | | - | |
| 1092 | + | |
| 1093 | + | |
| 1094 | + | |
| 1095 | + | |
1094 | 1096 | | |
1095 | 1097 | | |
1096 | 1098 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1013 | 1013 | | |
1014 | 1014 | | |
1015 | 1015 | | |
1016 | | - | |
| 1016 | + | |
| 1017 | + | |
| 1018 | + | |
| 1019 | + | |
| 1020 | + | |
1017 | 1021 | | |
1018 | 1022 | | |
1019 | 1023 | | |
1020 | 1024 | | |
1021 | 1025 | | |
1022 | | - | |
| 1026 | + | |
1023 | 1027 | | |
1024 | 1028 | | |
1025 | 1029 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
493 | 493 | | |
494 | 494 | | |
495 | 495 | | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
496 | 547 | | |
0 commit comments