a7f3452
From e95150836e332a2522b90382c8a1d4b56ac3ce26 Mon Sep 17 00:00:00 2001
a7f3452
From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <ppisar@redhat.com>
a7f3452
Date: Tue, 21 Jul 2015 16:15:07 +0200
a7f3452
Subject: [PATCH] Check for undefined stream format
a7f3452
MIME-Version: 1.0
a7f3452
Content-Type: text/plain; charset=UTF-8
a7f3452
Content-Transfer-Encoding: 8bit
a7f3452
a7f3452
format element is mandatory but the server will crash if it does not
a7f3452
exist in the configuration file. This patch handle the case
a7f3452
gracefully.
a7f3452
a7f3452
It does not raise an error on unsupported value because documentation
a7f3452
allows it.
a7f3452
a7f3452
<https://bugzilla.redhat.com/show_bug.cgi?id=1244481>
a7f3452
a7f3452
Signed-off-by: Petr Písař <ppisar@redhat.com>
a7f3452
---
a7f3452
 src/util.c | 5 +++++
a7f3452
 1 file changed, 5 insertions(+)
a7f3452
a7f3452
diff --git a/src/util.c b/src/util.c
a7f3452
index 9ecd430..20c2acc 100644
a7f3452
--- a/src/util.c
a7f3452
+++ b/src/util.c
a7f3452
@@ -135,6 +135,11 @@ stream_setup(const char *host, unsigned short port, const char *mount)
a7f3452
 		return (NULL);
a7f3452
 	}
a7f3452
 
a7f3452
+	if (NULL == pezConfig->format) {
a7f3452
+		printf("%s: stream format is missing\n", __progname);
a7f3452
+		shout_free(shout);
a7f3452
+		return (NULL);
a7f3452
+	}
a7f3452
 	if (!strcmp(pezConfig->format, MP3_FORMAT) &&
a7f3452
 	    shout_set_format(shout, SHOUT_FORMAT_MP3) != SHOUTERR_SUCCESS) {
a7f3452
 		printf("%s: shout_set_format(MP3): %s\n",
a7f3452
-- 
a7f3452
2.4.3
a7f3452