[vlc-devel] [PATCH] sdp: fix null format string passed to vsnprintf

Barmand Toumiret delthas at dille.cc
Tue Jul 23 18:09:44 CEST 2019

When rtcp-mux is used, sdp_AddAttribute is called with a null
format string, which means to write an SDP property attribute
(without value), which is a different from an empty format string,
that writes an SDP value attribute with an empty value.

This fixes vsdp_AddAttribute so that it correctly writes a
property attribute to the SDP description rather than incorrectly
calling vsnprintf with a null format string (an undefined behaviour
which segfaults on Windows) and writing a value attribute with
an empty value.
 src/stream_output/sdp.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/src/stream_output/sdp.c b/src/stream_output/sdp.c
index c57c611..dc13ec0 100644
--- a/src/stream_output/sdp.c
+++ b/src/stream_output/sdp.c
@@ -93,6 +93,11 @@ static bool IsSDPString (const char *str)
 static void vsdp_AddAttribute(struct vlc_memstream *restrict stream,
                               const char *name, const char *fmt, va_list ap)
+    if (fmt == NULL)
+    {
+        vlc_memstream_printf(stream, "a=%s\r\n", name);
+        return;
+    }
     vlc_memstream_printf(stream, "a=%s:", name);
     vlc_memstream_vprintf(stream, fmt, ap);
     vlc_memstream_puts(stream, "\r\n");

More information about the vlc-devel mailing list