diff options
author | Stefano Brivio <sbrivio@redhat.com> | 2022-03-15 23:17:44 +0100 |
---|---|---|
committer | Stefano Brivio <sbrivio@redhat.com> | 2022-03-29 15:35:38 +0200 |
commit | 3eb19cfd8a7c03920aeecae6692048429288af88 (patch) | |
tree | 88ffb6c69fab2da82a9d9910da1c57d34804d739 /udp.c | |
parent | 66a95e331ec930e72bc06c54b283ea88b30ecbaa (diff) | |
download | passt-3eb19cfd8a7c03920aeecae6692048429288af88.tar passt-3eb19cfd8a7c03920aeecae6692048429288af88.tar.gz passt-3eb19cfd8a7c03920aeecae6692048429288af88.tar.bz2 passt-3eb19cfd8a7c03920aeecae6692048429288af88.tar.lz passt-3eb19cfd8a7c03920aeecae6692048429288af88.tar.xz passt-3eb19cfd8a7c03920aeecae6692048429288af88.tar.zst passt-3eb19cfd8a7c03920aeecae6692048429288af88.zip |
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>
Diffstat (limited to 'udp.c')
-rw-r--r-- | udp.c | 7 |
1 files changed, 7 insertions, 0 deletions
@@ -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) { |