Commit 29dc8eb
Prevent undefined behavior when socket descriptor exceeds FD_SETSIZE (#27)
Cherry-pick fix from upstream libetpan PR #427.
When there are many open file descriptors (e.g., due to connection leaks
or high concurrency), socket descriptors can exceed FD_SETSIZE (typically
1024). Using FD_SET with such descriptors causes undefined behavior and
can corrupt memory or trigger runtime checks like glibc's __fdelt_chk.
This fix adds a bounds check before FD_SET to fail gracefully instead
of causing undefined behavior.
Note: Only the bug fix is cherry-picked; the unrelated configure.ac
optimization level change from the original PR is not included.
Upstream: dinhvh/libetpan#427
Co-authored-by: Claude <noreply@anthropic.com>1 parent cd47c42 commit 29dc8eb
1 file changed
+3
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
335 | 335 | | |
336 | 336 | | |
337 | 337 | | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
338 | 341 | | |
339 | 342 | | |
340 | 343 | | |
| |||
0 commit comments