]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
IPTV: udp:// - don't allow to receive non-raw UDP data, fixes #2470
authorJaroslav Kysela <perex@perex.cz>
Fri, 18 Mar 2016 15:09:57 +0000 (16:09 +0100)
committerJaroslav Kysela <perex@perex.cz>
Fri, 18 Mar 2016 15:09:57 +0000 (16:09 +0100)
src/input/mpegts/iptv/iptv_udp.c

index a264cda72fcfacbb72efebdba18b8e0494940cfa..25c8515797f5f1663416b3a7c8235c16399a5099 100644 (file)
@@ -79,16 +79,30 @@ iptv_udp_read ( iptv_mux_t *im )
   struct iovec *iovec;
   udp_multirecv_t *um = im->im_data;
   ssize_t res = 0;
+  char name[256];
 
   n = udp_multirecv_read(um, im->mm_iptv_fd, IPTV_PKTS, &iovec);
   if (n < 0)
     return -1;
 
+  im->mm_iptv_rtp_seq &= ~0xfff;
   for (i = 0; i < n; i++, iovec++) {
+    if (iovec->iov_len <= 0)
+      continue;
+    if (*(uint8_t *)iovec->iov_base != 0x47) {
+      im->mm_iptv_rtp_seq++;
+      continue;
+    }
     sbuf_append(&im->mm_iptv_buffer, iovec->iov_base, iovec->iov_len);
     res += iovec->iov_len;
   }
 
+  if (im->mm_iptv_rtp_seq < 0xffff && im->mm_iptv_rtp_seq > 0x3ff) {
+    mpegts_mux_nice_name((mpegts_mux_t*)im, name, sizeof(name));
+    tvherror("iptv", "receving non-raw UDP data for %s!", name);
+    im->mm_iptv_rtp_seq = 0x10000; /* no further logs! */
+  }
+
   return res;
 }