]> git.sesse.net Git - ffmpeg/blobdiff - libavformat/ty.c
Merge commit 'ac6691ab9938107d818cd8066ce3ea329ad14d8d'
[ffmpeg] / libavformat / ty.c
index 3926d3e9b705a5c040cc1537231fa26fac222398..02ab59aa2e1523136331b0a9425cb2421650519f 100644 (file)
@@ -249,7 +249,11 @@ static int analyze_chunk(AVFormatContext *s, const uint8_t *chunk)
      * in MPEG packets to determine tivo_type */
     if (ty->tivo_type == TIVO_TYPE_UNKNOWN) {
         uint32_t data_offset = 16 * num_recs;
+
         for (i = 0; i < num_recs; i++) {
+            if (data_offset + hdrs[i].rec_size > CHUNK_SIZE)
+                break;
+
             if ((hdrs[i].subrec_type << 0x08 | hdrs[i].rec_type) == 0x3c0 && hdrs[i].rec_size > 15) {
                 /* first make sure we're aligned */
                 int pes_offset = find_es_header(ty_MPEGAudioPacket,
@@ -534,14 +538,14 @@ static int check_sync_pes(AVFormatContext *s, AVPacket *pkt,
 
     if (offset < 0 || offset + ty->pes_length > rec_len) {
         /* entire PES header not present */
-        ff_dlog(s, "PES header at %d not complete in record. storing.\n", offset);
+        ff_dlog(s, "PES header at %"PRId32" not complete in record. storing.\n", offset);
         /* save the partial pes header */
         if (offset < 0) {
             /* no header found, fake some 00's (this works, believe me) */
             memset(ty->pes_buffer, 0, 4);
             ty->pes_buf_cnt = 4;
             if (rec_len > 4)
-                ff_dlog(s, "PES header not found in record of %d bytes!\n", rec_len);
+                ff_dlog(s, "PES header not found in record of %"PRId32" bytes!\n", rec_len);
             return -1;
         }
         /* copy the partial pes header we found */