mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2026-05-05 06:46:28 -04:00
netjack2: do some sanity checks on the MTU
It needs to be large enough foer the header, udp overhead and a uint32_t for each audio channel to be able to send the sync packet. Avoid string oob read when debugging the packet.
This commit is contained in:
parent
5a8a3b5a54
commit
67b70c8d23
2 changed files with 7 additions and 1 deletions
|
|
@ -133,7 +133,7 @@ struct nj2_packet_header {
|
|||
|
||||
static inline void nj2_dump_packet_header(struct nj2_packet_header *header)
|
||||
{
|
||||
pw_log_info("Type: %s", header->type);
|
||||
pw_log_info("Type: %.*s", (int)sizeof(header->type), header->type);
|
||||
pw_log_info("Data Type: %c", ntohl(header->data_type));
|
||||
pw_log_info("Data Stream: %c", ntohl(header->data_stream));
|
||||
pw_log_info("ID: %u", ntohl(header->id));
|
||||
|
|
|
|||
|
|
@ -156,6 +156,12 @@ static int netjack2_init(struct netjack2_peer *peer)
|
|||
errno = EINVAL;
|
||||
goto error_errno;
|
||||
}
|
||||
if (peer->params.mtu < UDP_HEADER_SIZE + sizeof(struct nj2_packet_header) ||
|
||||
sizeof(struct nj2_packet_header) +
|
||||
peer->params.recv_audio_channels * sizeof(int32_t) > peer->params.mtu) {
|
||||
errno = EINVAL;
|
||||
goto error_errno;
|
||||
}
|
||||
|
||||
if (peer->params.sample_encoder == NJ2_ENCODER_INT) {
|
||||
if (spa_overflow_mul(peer->params.period_size, (uint32_t)sizeof(int16_t), &peer->max_encoded_size) ||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue