Blob Blame History Raw
From e95150836e332a2522b90382c8a1d4b56ac3ce26 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <ppisar@redhat.com>
Date: Tue, 21 Jul 2015 16:15:07 +0200
Subject: [PATCH] Check for undefined stream format
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

format element is mandatory but the server will crash if it does not
exist in the configuration file. This patch handle the case
gracefully.

It does not raise an error on unsupported value because documentation
allows it.

<https://bugzilla.redhat.com/show_bug.cgi?id=1244481>

Signed-off-by: Petr Písař <ppisar@redhat.com>
---
 src/util.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/src/util.c b/src/util.c
index 9ecd430..20c2acc 100644
--- a/src/util.c
+++ b/src/util.c
@@ -135,6 +135,11 @@ stream_setup(const char *host, unsigned short port, const char *mount)
 		return (NULL);
 	}
 
+	if (NULL == pezConfig->format) {
+		printf("%s: stream format is missing\n", __progname);
+		shout_free(shout);
+		return (NULL);
+	}
 	if (!strcmp(pezConfig->format, MP3_FORMAT) &&
 	    shout_set_format(shout, SHOUT_FORMAT_MP3) != SHOUTERR_SUCCESS) {
 		printf("%s: shout_set_format(MP3): %s\n",
-- 
2.4.3