static void *
iptv_thread(void *aux)
{
- int nfds, fd, r, j;
+ int nfds, fd, r, j, hlen;
uint8_t tsb[65536], *buf;
struct epoll_event ev;
service_t *t;
if((tsb[1] & 0x7f) != 33)
continue;
- int hlen = (tsb[0] & 0xf) * 4 + 12;
+ hlen = (tsb[0] & 0xf) * 4 + 12;
+
+ if(tsb[0] & 0x10) {
+ // Extension (X bit) == true
+
+ if(r < hlen + 4)
+ continue; // Packet size < hlen + extension header
+
+ // Skip over extension header (last 2 bytes of header is length)
+ hlen += ((tsb[hlen + 2] << 8) | tsb[hlen + 3]) * 4;
+ }
if(r < hlen || (r - hlen) % 188 != 0)
continue;