From b3b1dd12a10c366bab87a26eeb6178778811e3e6 Mon Sep 17 00:00:00 2001 From: Philipp Schafft Date: Sat, 29 Oct 2016 11:42:52 +0000 Subject: [PATCH] Workaround: This avoids libspeex printing warnings on Opus streams. libspeex reports warnings in case of oddnesses with the data to stderr. However Icecast2 uses those functions in it's codec probeing process. This way libspeex will write messages to a posibily reused random handle. This is clearly a bug by package maintainers of libspeex. See the source code of this change as well as libspeex's source code as reference. --- src/format_speex.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/format_speex.c b/src/format_speex.c index e7f6701c..ed3dd82a 100644 --- a/src/format_speex.c +++ b/src/format_speex.c @@ -73,6 +73,19 @@ ogg_codec_t *initial_speex_page (format_plugin_t *plugin, ogg_page *page) ogg_stream_packetout (&codec->os, &packet); + /* Check for te first packet to be at least of the minimal size for a Speex header. + * The header size is 80 bytes as per specs. You can find the specs here: + * https://speex.org/docs/manual/speex-manual/node8.html#SECTION00830000000000000000 + * + * speex_packet_to_header() will also check the header size for us. However + * that function generates noise on stderr in case the header is too short. + * This is dangerous as we may have closed stderr already and the handle may be use + * again for something else. + */ + if (packet.bytes < 80) { + return NULL; + } + ICECAST_LOG_DEBUG("checking for speex codec"); header = speex_packet_to_header ((char*)packet.packet, packet.bytes); if (header == NULL) -- GitLab