From 2952a29c1ef96b3ac3844162696d5ad1778ac0fe Mon Sep 17 00:00:00 2001 From: Philipp Schafft Date: Fri, 17 Mar 2023 15:18:41 +0000 Subject: [PATCH] Fix: Converted source->format->contenttype into a igloo string pool string --- src/format_ebml.c | 8 +++++++- src/format_mp3.c | 14 +++++++++++--- src/format_ogg.c | 9 ++++++++- src/format_text.c | 8 +++++++- src/source.c | 7 +++++-- 5 files changed, 38 insertions(+), 8 deletions(-) diff --git a/src/format_ebml.c b/src/format_ebml.c index b3318904..a4b1d943 100644 --- a/src/format_ebml.c +++ b/src/format_ebml.c @@ -26,6 +26,10 @@ #include #include +#include +#include + +#include "global.h" #include "refbuf.h" #include "source.h" #include "client.h" @@ -211,7 +215,9 @@ int format_ebml_get_plugin(source_t *source) plugin->set_tag = NULL; plugin->apply_settings = NULL; - plugin->contenttype = httpp_getvar(source->parser, "content-type"); + if (igloo_sp_replace(httpp_getvar(source->parser, "content-type"), &(plugin->contenttype), igloo_instance) != igloo_ERROR_NONE) { + ICECAST_LOG_ERROR("Cannot set content type for EBML source %#H. BAD.", source->mount); + } plugin->_state = ebml_source_state; vorbis_comment_init(&plugin->vc); diff --git a/src/format_mp3.c b/src/format_mp3.c index 53afbc36..8af8178b 100644 --- a/src/format_mp3.c +++ b/src/format_mp3.c @@ -30,6 +30,9 @@ # include #endif +#include +#include + #include "global.h" #include "refbuf.h" #include "event.h" @@ -78,6 +81,7 @@ int format_mp3_get_plugin(source_t *source) format_plugin_t *plugin; mp3_state *state = calloc(1, sizeof(mp3_state)); refbuf_t *meta; + const char *contenttype; plugin = (format_plugin_t *) calloc(1, sizeof(format_plugin_t)); @@ -90,10 +94,14 @@ int format_mp3_get_plugin(source_t *source) plugin->set_tag = mp3_set_tag; plugin->apply_settings = format_mp3_apply_settings; - plugin->contenttype = httpp_getvar(source->parser, "content-type"); - if (plugin->contenttype == NULL) { + contenttype = httpp_getvar(source->parser, "content-type"); + if (contenttype == NULL) { /* We default to MP3 audio for old clients without content types */ - plugin->contenttype = "audio/mpeg"; + contenttype = "audio/mpeg"; + } + + if (igloo_sp_replace(contenttype, &(plugin->contenttype), igloo_instance) != igloo_ERROR_NONE) { + ICECAST_LOG_ERROR("Cannot set content type for legacy source %#H. BAD.", source->mount); } plugin->_state = state; diff --git a/src/format_ogg.c b/src/format_ogg.c index b92bf5cf..3ffaecdd 100644 --- a/src/format_ogg.c +++ b/src/format_ogg.c @@ -27,6 +27,10 @@ #include +#include +#include + +#include "global.h" #include "refbuf.h" #include "source.h" #include "client.h" @@ -178,7 +182,10 @@ int format_ogg_get_plugin(source_t *source) plugin->set_tag = NULL; if (strcmp (httpp_getvar (source->parser, "content-type"), "application/x-ogg") == 0) httpp_setvar (source->parser, "content-type", "application/ogg"); - plugin->contenttype = httpp_getvar (source->parser, "content-type"); + + if (igloo_sp_replace(httpp_getvar(source->parser, "content-type"), &(plugin->contenttype), igloo_instance) != igloo_ERROR_NONE) { + ICECAST_LOG_ERROR("Cannot set content type for Ogg source %#H. BAD.", source->mount); + } ogg_sync_init (&state->oy); vorbis_comment_init(&plugin->vc); diff --git a/src/format_text.c b/src/format_text.c index 5232da00..27c34566 100644 --- a/src/format_text.c +++ b/src/format_text.c @@ -15,6 +15,10 @@ #include #include +#include +#include + +#include "global.h" #include "source.h" #include "format.h" #include "format_text.h" @@ -105,7 +109,9 @@ int format_text_get_plugin(source_t *source) plugin->set_tag = NULL; plugin->apply_settings = NULL; - plugin->contenttype = httpp_getvar(source->parser, "content-type"); + if (igloo_sp_replace(httpp_getvar(source->parser, "content-type"), &(plugin->contenttype), igloo_instance) != igloo_ERROR_NONE) { + ICECAST_LOG_ERROR("Cannot set content type for text source %#H. BAD.", source->mount); + } skip = httpp_getvar(source->parser, "x-icecast-text-skip-char"); if (skip) { diff --git a/src/source.c b/src/source.c index 94d0d044..a91a4ee9 100644 --- a/src/source.c +++ b/src/source.c @@ -237,8 +237,11 @@ void source_clear_source (source_t *source) source->parser = NULL; source->con = NULL; - if (source->format) - source->format->contenttype = NULL; + if (source->format) { + if (igloo_sp_unref(&(source->format->contenttype), igloo_instance) != igloo_ERROR_NONE) { + ICECAST_LOG_ERROR("Cannot unref content type for source %#H", source->mount); + } + } /* log bytes read in access log */ if (source->client && source->format)