From: Jaroslav Kysela Date: Tue, 8 Dec 2015 13:10:43 +0000 (+0100) Subject: profile: pro_name might be NULL under some circumstances, fixes #3397 X-Git-Tag: v4.2.1~1341 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=3ae4164fb3348db47cd035652cc63dfc93a4a2eb;p=thirdparty%2Ftvheadend.git profile: pro_name might be NULL under some circumstances, fixes #3397 --- diff --git a/src/access.c b/src/access.c index d0eb810b5..ade3f5a20 100644 --- a/src/access.c +++ b/src/access.c @@ -434,7 +434,7 @@ access_dump_a(access_t *a) if (first) tvh_strlcatf(buf, sizeof(buf), l, ", profile="); tvh_strlcatf(buf, sizeof(buf), l, "%s'%s'", - first ? "" : ",", pro->pro_name ?: ""); + first ? "" : ",", profile_get_name(pro)); first = 0; } } diff --git a/src/dvr/dvr_rec.c b/src/dvr/dvr_rec.c index c32df4364..f8e6aaea5 100644 --- a/src/dvr/dvr_rec.c +++ b/src/dvr/dvr_rec.c @@ -115,12 +115,12 @@ dvr_rec_subscribe(dvr_entry_t *de) if (profile_chain_open(prch, &de->de_config->dvr_muxcnf, 0, 0)) { profile_chain_close(prch); tvherror("dvr", "unable to create new channel streaming chain '%s' for '%s', using default", - pro->pro_name, channel_get_name(de->de_channel)); + profile_get_name(pro), channel_get_name(de->de_channel)); pro = profile_find_by_name(NULL, NULL); profile_chain_init(prch, pro, de->de_channel); if (profile_chain_open(prch, &de->de_config->dvr_muxcnf, 0, 0)) { tvherror("dvr", "unable to create channel streaming default chain '%s' for '%s'", - pro->pro_name, channel_get_name(de->de_channel)); + profile_get_name(pro), channel_get_name(de->de_channel)); profile_chain_close(prch); free(prch); return -EINVAL; @@ -132,7 +132,7 @@ dvr_rec_subscribe(dvr_entry_t *de) NULL, NULL, NULL, NULL); if (de->de_s == NULL) { tvherror("dvr", "unable to create new channel subcription for '%s' profile '%s'", - channel_get_name(de->de_channel), pro->pro_name); + channel_get_name(de->de_channel), profile_get_name(pro)); profile_chain_close(prch); free(prch); return -EINVAL; diff --git a/src/htsp_server.c b/src/htsp_server.c index 2876d9d7f..ce79c733d 100644 --- a/src/htsp_server.c +++ b/src/htsp_server.c @@ -2330,7 +2330,7 @@ htsp_method_subscribe(htsp_connection_t *htsp, htsmsg_t *in) "htsp", SUBSCRIPTION_PACKET | SUBSCRIPTION_HTSP); profile_chain_init(&hs->hs_prch, pro, ch); if (profile_chain_work(&hs->hs_prch, &hs->hs_input, timeshiftPeriod, 0)) { - tvhlog(LOG_ERR, "htsp", "unable to create profile chain '%s'", pro->pro_name); + tvhlog(LOG_ERR, "htsp", "unable to create profile chain '%s'", profile_get_name(pro)); profile_chain_close(&hs->hs_prch); free(hs); return htsp_error("Stream setup error"); @@ -2365,7 +2365,7 @@ htsp_method_subscribe(htsp_connection_t *htsp, htsmsg_t *in) LIST_INSERT_HEAD(&htsp->htsp_subscriptions, hs, hs_link); tvhdebug("htsp", "%s - subscribe to %s using profile %s", - htsp->htsp_logname, channel_get_name(ch), pro->pro_name ?: ""); + htsp->htsp_logname, channel_get_name(ch), profile_get_name(pro)); hs->hs_s = subscription_create_from_channel(&hs->hs_prch, NULL, weight, htsp->htsp_logname, SUBSCRIPTION_PACKET | diff --git a/src/profile.c b/src/profile.c index 258790099..4d3423316 100644 --- a/src/profile.c +++ b/src/profile.c @@ -416,13 +416,13 @@ profile_find_by_name2(const char *name, const char *alt, int all) return profile_default; TAILQ_FOREACH(pro, &profiles, pro_link) { - if ((all || pro->pro_enabled) && !strcmp(pro->pro_name, name)) + if ((all || pro->pro_enabled) && !strcmp(profile_get_name(pro), name)) return pro; } if (alt) { TAILQ_FOREACH(pro, &profiles, pro_link) { - if ((all || pro->pro_enabled) && !strcmp(pro->pro_name, alt)) + if ((all || pro->pro_enabled) && !strcmp(profile_get_name(pro), alt)) return pro; } } @@ -506,12 +506,12 @@ profile_validate_name(const char *name) lock_assert(&global_lock); TAILQ_FOREACH(pro, &profiles, pro_link) { - if (name && !strcmp(pro->pro_name, name)) + if (name && !strcmp(profile_get_name(pro), name)) return strdup(name); } if (profile_default) - return strdup(profile_default->pro_name); + return strdup(profile_get_name(profile_default)); return NULL; } @@ -1892,7 +1892,7 @@ profile_init(void) name = "pass"; pro = profile_find_by_name2(name, NULL, 1); - if (pro == NULL || strcmp(pro->pro_name, name)) { + if (pro == NULL || strcmp(profile_get_name(pro), name)) { htsmsg_t *conf; conf = htsmsg_create_map(); @@ -1913,7 +1913,7 @@ profile_init(void) name = "matroska"; pro = profile_find_by_name2(name, NULL, 1); - if (pro == NULL || strcmp(pro->pro_name, name)) { + if (pro == NULL || strcmp(profile_get_name(pro), name)) { htsmsg_t *conf; conf = htsmsg_create_map(); @@ -1929,7 +1929,7 @@ profile_init(void) name = "htsp"; pro = profile_find_by_name2(name, NULL, 1); - if (pro == NULL || strcmp(pro->pro_name, name)) { + if (pro == NULL || strcmp(profile_get_name(pro), name)) { htsmsg_t *conf; conf = htsmsg_create_map(); @@ -1947,7 +1947,7 @@ profile_init(void) name = "webtv-vp8-vorbis-webm"; pro = profile_find_by_name2(name, NULL, 1); - if (pro == NULL || strcmp(pro->pro_name, name)) { + if (pro == NULL || strcmp(profile_get_name(pro), name)) { htsmsg_t *conf; conf = htsmsg_create_map(); @@ -1967,7 +1967,7 @@ profile_init(void) } name = "webtv-h264-aac-mpegts"; pro = profile_find_by_name2(name, NULL, 1); - if (pro == NULL || strcmp(pro->pro_name, name)) { + if (pro == NULL || strcmp(profile_get_name(pro), name)) { htsmsg_t *conf; conf = htsmsg_create_map(); @@ -1987,7 +1987,7 @@ profile_init(void) } name = "webtv-h264-aac-matroska"; pro = profile_find_by_name2(name, NULL, 1); - if (pro == NULL || strcmp(pro->pro_name, name)) { + if (pro == NULL || strcmp(profile_get_name(pro), name)) { htsmsg_t *conf; conf = htsmsg_create_map(); diff --git a/src/subscriptions.c b/src/subscriptions.c index d07ef025d..b7ca2a781 100644 --- a/src/subscriptions.c +++ b/src/subscriptions.c @@ -242,9 +242,8 @@ subscription_show_info(th_subscription_t *s) tvh_strlcatf(buf, sizeof(buf), l, ", service: \"%s\"", si.si_service); if (s->ths_prch && s->ths_prch->prch_pro) - tvh_strlcatf(buf, sizeof(buf), l, - ", profile=\"%s\"", - s->ths_prch->prch_pro->pro_name ?: ""); + tvh_strlcatf(buf, sizeof(buf), l, ", profile=\"%s\"", + profile_get_name(s->ths_prch->prch_pro)); if (s->ths_hostname) tvh_strlcatf(buf, sizeof(buf), l, ", hostname=\"%s\"", s->ths_hostname); @@ -765,7 +764,7 @@ subscription_create_from_channel_or_service(profile_chain_t *prch, s = subscription_create(prch, weight, name, flags, subscription_input, hostname, username, client); if (tvhtrace_enabled()) { - const char *pro_name = prch->prch_pro ? (prch->prch_pro->pro_name ?: "") : ""; + const char *pro_name = prch->prch_pro ? profile_get_name(prch->prch_pro) : ""; if (ch) tvhtrace("subscription", "%04X: creating subscription for %s weight %d using profile %s", shortid(s), channel_get_name(ch), weight, pro_name);