Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
psip: fix the broken logic, fixes #3239
  • Loading branch information
perexg committed Nov 1, 2015
1 parent 798b481 commit 18d993f
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/epggrab/module/psip.c
Expand Up @@ -71,7 +71,7 @@ typedef struct psip_event

static int
_psip_eit_callback_channel
(epggrab_module_t *mod, channel_t *ch, const uint8_t *ptr, int count)
(epggrab_module_t *mod, channel_t *ch, const uint8_t *ptr, int len, int count)
{
uint16_t eventid;
uint32_t starttime, length;
Expand All @@ -84,7 +84,7 @@ _psip_eit_callback_channel
epg_episode_t *ee;
lang_str_t *title;

for (i = 0; i + 12 <= count; i += size, ptr += size) {
for (i = 0; len >= 12 && i < count; len -= size, ptr += size, i++) {
eventid = (ptr[0] & 0x3f) << 8 | ptr[1];
starttime = ptr[2] << 24 | ptr[3] << 16 | ptr[4] << 8 | ptr[5];
start = atsc_convert_gpstime(starttime);
Expand All @@ -95,7 +95,7 @@ _psip_eit_callback_channel
size = titlelen + dlen + 12;
// tvhtrace("psip", " %03d: titlelen %d, dlen %d", i, titlelen, dlen);

if (size > count) break;
if (size > len) break;

atsc_get_string(buf, sizeof(buf), &ptr[10], titlelen, "eng");

Expand Down Expand Up @@ -175,7 +175,7 @@ _psip_eit_callback
len -= 7;

/* Sanity check */
if (count > len) goto done;
if (len < 12) goto done;

/* Register this */
if (ota)
Expand All @@ -185,7 +185,7 @@ _psip_eit_callback
LIST_FOREACH(ilm, &svc->s_channels, ilm_in1_link) {
ch = (channel_t *)ilm->ilm_in2;
if (!ch->ch_enabled || ch->ch_epg_parent) continue;
save |= _psip_eit_callback_channel(mod, ch, ptr, count);
save |= _psip_eit_callback_channel(mod, ch, ptr, len, count);
}

if (save)
Expand Down

0 comments on commit 18d993f

Please sign in to comment.