Merge commit 'addbaf134836aea4e14f73add8c6d753a1373257' into release/1.1
authorMichael Niedermayer <michaelni@gmx.at>
Sat, 30 Aug 2014 18:21:17 +0000 (20:21 +0200)
committerMichael Niedermayer <michaelni@gmx.at>
Sat, 30 Aug 2014 18:31:50 +0000 (20:31 +0200)
* commit 'addbaf134836aea4e14f73add8c6d753a1373257':
  mpegts: Do not try to write a PMT larger than SECTION_SIZE

Conflicts:
libavformat/mpegtsenc.c

See: 694c3a13c9489c6e05f88486b489dd0746d114fc
Merged-by: Michael Niedermayer <michaelni@gmx.at>
1  2 
libavformat/mpegtsenc.c

@@@ -281,6 -272,11 +281,11 @@@ static int mpegts_write_pmt(AVFormatCon
          AVStream *st = s->streams[i];
          MpegTSWriteStream *ts_st = st->priv_data;
          AVDictionaryEntry *lang = av_dict_get(st->metadata, "language", NULL,0);
 -        if (q - data > SECTION_LENGTH - 3 - 2 - 6) {
++        if (q - data > SECTION_LENGTH - 32) {
+             err = 1;
+             break;
+         }
          switch(st->codec->codec_id) {
          case AV_CODEC_ID_MPEG1VIDEO:
          case AV_CODEC_ID_MPEG2VIDEO:
              stream_type = STREAM_TYPE_PRIVATE_DATA;
              break;
          }
-         if (q - data > sizeof(data) - 32)
-             return AVERROR(EINVAL);
 +
 +
          *q++ = stream_type;
          put16(&q, 0xe000 | ts_st->pid);
          desc_length_ptr = q;
          desc_length_ptr[0] = val >> 8;
          desc_length_ptr[1] = val;
      }
+     if (err)
+         av_log(s, AV_LOG_ERROR,
+                "The PMT section is too small for stream %d and following.\n"
+                "Try reducing the number of languages in the audio streams "
+                "or the total number of streams.\n",
+                i);
      mpegts_write_section1(&service->pmt, PMT_TID, service->sid, 0, 0, 0,
                            data, q - data);
 +    return 0;
  }
  
  /* NOTE: str == NULL is accepted for an empty string */