From c37c6b0789e8541c4110d110295a37addddf37a0 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Fri, 16 Feb 2024 12:51:34 +0100 Subject: [PATCH] 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 --- src/modules/module-rtp-sap.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/modules/module-rtp-sap.c b/src/modules/module-rtp-sap.c index e5e480603..3dca46dcd 100644 --- a/src/modules/module-rtp-sap.c +++ b/src/modules/module-rtp-sap.c @@ -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)); } }