Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
profile: pro_name might be NULL under some circumstances, fixes #3397
  • Loading branch information
perexg committed Dec 8, 2015
1 parent e46cde6 commit 3ae4164
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 20 deletions.
2 changes: 1 addition & 1 deletion src/access.c
Expand Up @@ -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;
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/dvr/dvr_rec.c
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/htsp_server.c
Expand Up @@ -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");
Expand Down Expand Up @@ -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 |
Expand Down
20 changes: 10 additions & 10 deletions src/profile.c
Expand Up @@ -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;
}
}
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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();
Expand All @@ -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();
Expand All @@ -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();
Expand All @@ -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();
Expand All @@ -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();
Expand All @@ -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();
Expand Down
7 changes: 3 additions & 4 deletions src/subscriptions.c
Expand Up @@ -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);
Expand Down Expand Up @@ -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 ?: "") : "<none>";
const char *pro_name = prch->prch_pro ? profile_get_name(prch->prch_pro) : "<none>";
if (ch)
tvhtrace("subscription", "%04X: creating subscription for %s weight %d using profile %s",
shortid(s), channel_get_name(ch), weight, pro_name);
Expand Down

0 comments on commit 3ae4164

Please sign in to comment.