module-rtp: fix SAP header parsing for IPv6

If the originating source is IPv6, the A bit is set and the source is 16
bytes compared to 4 bytes for IPv4.

Fixes #3851
This commit is contained in:
Wim Taymans 2024-02-16 12:51:34 +01:00
parent e15b9e7f71
commit c37c6b0789

View file

@ -1423,7 +1423,7 @@ static int parse_sap(struct impl *impl, void *data, size_t len)
if (header->c)
return -ENOTSUP;
offs = header->a ? 12 : 8;
offs = header->a ? 20 : 8;
offs += header->auth_len * 4;
if (len <= offs)
return -EINVAL;
@ -1463,6 +1463,7 @@ static void
on_sap_io(void *data, int fd, uint32_t mask)
{
struct impl *impl = data;
int res;
if (mask & SPA_IO_IN) {
uint8_t buffer[2048];
@ -1476,7 +1477,8 @@ on_sap_io(void *data, int fd, uint32_t mask)
return;
buffer[len] = 0;
parse_sap(impl, buffer, len);
if ((res = parse_sap(impl, buffer, len)) < 0)
pw_log_warn("error parsing SAP: %s", spa_strerror(res));
}
}