From 16dac2505e08155993302ddca1e9e34c4b45e2ca Mon Sep 17 00:00:00 2001 From: Marvin Scholz Date: Sat, 6 Jun 2015 14:06:48 +0200 Subject: [PATCH] Fix that global listener count could be negative under certain circumstances MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This fixes a bug that could cause the global listener count of Icecast to be negative. This was caused due to wrong handling of errors in the format_prepare_headers function. Fixes: #2199 Thanks a lot to Simeon Völkel (0xBD4E031CDB4043C9) for reporting and investigating the bug. --- src/format.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/format.c b/src/format.c index 8e7dce4e..9d50b4be 100644 --- a/src/format.c +++ b/src/format.c @@ -408,8 +408,12 @@ static int format_prepare_headers (source_t *source, client_t *client) client->refbuf->len -= remaining; if (source->format->create_client_data) - if (source->format->create_client_data (source, client) < 0) + if (source->format->create_client_data (source, client) < 0) { + ICECAST_LOG_ERROR("Client format header generation failed. " + "(Likely not enough or wrong source data) Dropping client."); + client->respcode = 500; return -1; + } return 0; }