aboutgitcodebugslistschat
path: root/tcp_splice.c
diff options
context:
space:
mode:
authorStefano Brivio <sbrivio@redhat.com>2022-03-15 23:17:44 +0100
committerStefano Brivio <sbrivio@redhat.com>2022-03-29 15:35:38 +0200
commit3eb19cfd8a7c03920aeecae6692048429288af88 (patch)
tree88ffb6c69fab2da82a9d9910da1c57d34804d739 /tcp_splice.c
parent66a95e331ec930e72bc06c54b283ea88b30ecbaa (diff)
downloadpasst-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 'tcp_splice.c')
-rw-r--r--tcp_splice.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/tcp_splice.c b/tcp_splice.c
index cb8df7b..d374785 100644
--- a/tcp_splice.c
+++ b/tcp_splice.c
@@ -418,6 +418,14 @@ static int tcp_splice_connect(struct ctx *c, struct tcp_splice_conn *conn,
const struct sockaddr *sa;
socklen_t sl;
+ if (sock_conn < 0)
+ return -errno;
+
+ if (sock_conn > SOCKET_MAX) {
+ close(sock_conn);
+ return -EIO;
+ }
+
conn->b = sock_conn;
if (s < 0)