connection: return error if too many fds in message

Check that the number of fds in the message doesn't exceed our max or
else we might overflow the fd buffer a little later.
This commit is contained in:
Wim Taymans 2026-05-14 16:32:58 +02:00
parent 79b4aba6cc
commit f3fc645496

View file

@ -538,7 +538,8 @@ static int prepare_packet(struct pw_protocol_native_connection *conn, struct buf
size -= impl->hdr_size;
buf->msg.fds = &buf->fds[buf->fds_offset];
if (buf->msg.n_fds + buf->fds_offset > buf->n_fds)
if (buf->msg.n_fds > MAX_FDS ||
buf->msg.n_fds + buf->fds_offset > buf->n_fds)
return -EPROTO;
if (size < len)