From 3eb19cfd8a7c03920aeecae6692048429288af88 Mon Sep 17 00:00:00 2001 From: Stefano Brivio Date: Tue, 15 Mar 2022 23:17:44 +0100 Subject: 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 --- udp.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'udp.c') diff --git a/udp.c b/udp.c index ad8a775..e22f3ac 100644 --- a/udp.c +++ b/udp.c @@ -443,8 +443,15 @@ int udp_splice_connect(struct ctx *c, int v6, int bound_sock, s = socket(v6 ? AF_INET6 : AF_INET, SOCK_DGRAM | SOCK_NONBLOCK, IPPROTO_UDP); + + if (s > SOCKET_MAX) { + close(s); + return -EIO; + } + if (s < 0) return s; + ref.r.s = s; if (v6) { -- cgit v1.2.3