tcp, udp, util: Enforce 24-bit limit on socket numbers

This should never happen, but there are no formal guarantees: ensure
socket numbers are below SOCKET_MAX.

Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
This commit is contained in:
Stefano Brivio
2022-03-15 23:17:44 +01:00
parent 66a95e331e
commit 3eb19cfd8a
5 changed files with 42 additions and 1 deletions

View File

@@ -45,7 +45,9 @@ union epoll_ref;
union epoll_ref {
struct {
int32_t proto:8,
s:24;
#define SOCKET_REF_BITS 24
#define SOCKET_MAX (1 << SOCKET_REF_BITS)
s:SOCKET_REF_BITS;
union {
union tcp_epoll_ref tcp;
union udp_epoll_ref udp;