Merge commit 'e6496ea7e7ea7355167a1ccbe67a7199d446a654'
authorMichael Niedermayer <michaelni@gmx.at>
Thu, 13 Jun 2013 07:50:42 +0000 (09:50 +0200)
committerMichael Niedermayer <michaelni@gmx.at>
Thu, 13 Jun 2013 07:50:42 +0000 (09:50 +0200)
* commit 'e6496ea7e7ea7355167a1ccbe67a7199d446a654':
  4xm: K&R formatting cosmetics

Conflicts:
libavformat/4xm.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
1  2 
libavformat/4xm.c

@@@ -127,17 -127,9 +127,17 @@@ static int fourxm_read_header(AVFormatC
      /* take the lazy approach and search for any and all vtrk and strk chunks */
      for (i = 0; i < header_size - 8; i++) {
          fourcc_tag = AV_RL32(&header[i]);
-         size = AV_RL32(&header[i + 4]);
+         size       = AV_RL32(&header[i + 4]);
 +        if (size > header_size - i - 8 && (fourcc_tag == vtrk_TAG || fourcc_tag == strk_TAG)) {
 +            av_log(s, AV_LOG_ERROR, "chunk larger than array %d>%d\n", size, header_size - i - 8);
 +            return AVERROR_INVALIDDATA;
 +        }
  
          if (fourcc_tag == std__TAG) {
 +            if (header_size < i + 16) {
 +                av_log(s, AV_LOG_ERROR, "std TAG truncated\n");
 +                return AVERROR_INVALIDDATA;
 +            }
              fourxm->fps = av_int2float(AV_RL32(&header[i + 12]));
          } else if (fourcc_tag == vtrk_TAG) {
              /* check that there is enough data */
              fourxm->tracks[current_track].sample_rate = AV_RL32(&header[i + 40]);
              fourxm->tracks[current_track].bits        = AV_RL32(&header[i + 44]);
              fourxm->tracks[current_track].audio_pts   = 0;
-             if(   fourxm->tracks[current_track].channels    <= 0
-                || fourxm->tracks[current_track].sample_rate <= 0
-                || fourxm->tracks[current_track].bits        <  0){
+             if (fourxm->tracks[current_track].channels    <= 0 ||
+                 fourxm->tracks[current_track].sample_rate <= 0 ||
+                 fourxm->tracks[current_track].bits        < 0) {
                  av_log(s, AV_LOG_ERROR, "audio header invalid\n");
 -                ret = -1;
 +                ret = AVERROR_INVALIDDATA;
 +                goto fail;
 +            }
 +            if(!fourxm->tracks[current_track].adpcm && fourxm->tracks[current_track].bits<8){
 +                av_log(s, AV_LOG_ERROR, "bits unspecified for non ADPCM\n");
 +                ret = AVERROR_INVALIDDATA;
                  goto fail;
              }
              i += 8 + size;
@@@ -275,15 -262,13 +276,13 @@@ static int fourxm_read_packet(AVFormatC
          if ((ret = avio_read(s->pb, header, 8)) < 0)
              return ret;
          fourcc_tag = AV_RL32(&header[0]);
-         size = AV_RL32(&header[4]);
+         size       = AV_RL32(&header[4]);
 -        if (pb->eof_reached)
 +        if (url_feof(pb))
              return AVERROR(EIO);
          switch (fourcc_tag) {
          case LIST_TAG:
              /* this is a good time to bump the video pts */
-             fourxm->video_pts ++;
+             fourxm->video_pts++;
  
              /* skip the LIST-* tag and move on to the next fourcc */
              avio_rl32(pb);