From a8ce127dee2669bd641b039b9725f4ea3cc71942 Mon Sep 17 00:00:00 2001 From: Adam Sutton Date: Mon, 23 Dec 2013 22:37:27 +0000 Subject: [PATCH] epggrab: ensure / in channel ID doesn't cause config failure. Fixes #1774. --- src/epggrab/channel.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/epggrab/channel.c b/src/epggrab/channel.c index d53534a3..974bcf38 100644 --- a/src/epggrab/channel.c +++ b/src/epggrab/channel.c @@ -16,9 +16,6 @@ * along with this program. If not, see . */ -#include -#include - #include "tvheadend.h" #include "settings.h" #include "htsmsg.h" @@ -27,6 +24,9 @@ #include "epggrab.h" #include "epggrab/private.h" +#include +#include + /* ************************************************************************** * EPG Grab Channel functions * *************************************************************************/ @@ -187,10 +187,19 @@ epggrab_channel_t *epggrab_channel_find ( epggrab_channel_tree_t *tree, const char *id, int create, int *save, epggrab_module_t *owner ) { + char *s; epggrab_channel_t *ec; static epggrab_channel_t *skel = NULL; if (!skel) skel = calloc(1, sizeof(epggrab_channel_t)); - skel->id = (char*)id; + skel->id = strdupa(id); + + /* Replace / with # */ + // Note: this is a bit of a nasty fix for #1774, but will do for now + s = skel->id; + while (*s) { + if (*s == '/') *s = '#'; + s++; + } /* Find */ if (!create) { @@ -202,9 +211,9 @@ epggrab_channel_t *epggrab_channel_find if (!ec) { assert(owner); ec = skel; - skel = NULL; - ec->id = strdup(id); + ec->id = strdup(skel->id); ec->mod = owner; + skel = NULL; *save = 1; } }