Add protection to stop opentv crashing on bad title descriptor. Relates to #1367.

This commit is contained in:
Adam Sutton 2012-10-30 17:27:54 +00:00
parent f83df17715
commit d761985f3b

View file

@ -217,6 +217,8 @@ static char *_opentv_parse_string
int ok = 0; int ok = 0;
char *ret, *tmp; char *ret, *tmp;
if (len <= 0) return NULL;
// Note: unlikely decoded string will be longer (though its possible) // Note: unlikely decoded string will be longer (though its possible)
ret = tmp = malloc(2*len); ret = tmp = malloc(2*len);
*ret = 0; *ret = 0;
@ -248,15 +250,17 @@ static int _opentv_parse_event_record
if (rlen+2 <= len) { if (rlen+2 <= len) {
switch (rtag) { switch (rtag) {
case 0xb5: // title case 0xb5: // title
ev->start = (((int)buf[2] << 9) | (buf[3] << 1)) if (rlen >= 7) {
+ mjd; ev->start = (((int)buf[2] << 9) | (buf[3] << 1))
ev->stop = (((int)buf[4] << 9) | (buf[5] << 1)) + mjd;
+ ev->start; ev->stop = (((int)buf[4] << 9) | (buf[5] << 1))
ev->cat = buf[6]; + ev->start;
if (prov->genre) ev->cat = buf[6];
ev->cat = prov->genre->map[ev->cat]; if (prov->genre)
if (!ev->title) ev->cat = prov->genre->map[ev->cat];
ev->title = _opentv_parse_string(prov, buf+9, rlen-7); if (!ev->title)
ev->title = _opentv_parse_string(prov, buf+9, rlen-7);
}
break; break;
case 0xb9: // summary case 0xb9: // summary
if (!ev->summary) if (!ev->summary)