Opened 5 years ago

Closed 5 years ago

Last modified 4 years ago

#1064 closed defect (fixed)

Div/0 integer exception cased in aiffdec.c for A-Law AIFFs

Reported by: dmitrykos Owned by:
Priority: important Component: avformat
Version: git-master Keywords: aif
Cc: Blocked By:
Blocking: Reproduced by developer: yes
Analyzed by developer: no

Description

Hi,

Divizion by 0 integer exception is raised in aiffdec.c, line 163:

    codec->bit_rate = codec->sample_rate * (codec->block_align << 3) /
                      aiff->block_duration;

if AIFF file is in A-Law format, or any format which is not processed by 'case' starting at line 120.

It is possible to fix it by adding:

aiff->block_duration = 1;

inside 'default' of this 'case'.

So the code will look like this:

        switch (codec->codec_id) {
        case CODEC_ID_PCM_S16BE:
            codec->codec_id = aiff_codec_get_id(codec->bits_per_coded_sample);
            codec->bits_per_coded_sample = av_get_bits_per_sample(codec->codec_id);
            aiff->block_duration = 1;
            break;
        case CODEC_ID_ADPCM_IMA_QT:
            codec->block_align = 34*codec->channels;
            aiff->block_duration = 64;
            break;
        case CODEC_ID_MACE3:
            codec->block_align = 2*codec->channels;
            aiff->block_duration = 6;
            break;
        case CODEC_ID_MACE6:
            codec->block_align = 1*codec->channels;
            aiff->block_duration = 6;
            break;
        case CODEC_ID_GSM:
            codec->block_align = 33;
            aiff->block_duration = 160;
            break;
        case CODEC_ID_QCELP:
            codec->block_align = 35;
            aiff->block_duration = 160;
            break;
        default:
            aiff->block_duration = 1; //!< avoid Div/0
            break;
        }

Change History (4)

comment:1 Changed 5 years ago by cehoyos

  • Component changed from FFmpeg to avformat
  • Keywords aiff added
  • Priority changed from critical to important
  • Reproduced by developer set
  • Status changed from new to open
$ ffmpeg -i input -acodec pcm_alaw out.aiff

...

(gdb) r -i out.aiff
Starting program: /home/cehoyos/Projects/ffmpeg/ffmpeg_g -i out.aiff
[Thread debugging using libthread_db enabled]
[New Thread 0xb7c056c0 (LWP 25589)]
ffmpeg version N-38765-ge05253b Copyright (c) 2000-2012 the FFmpeg developers
  built on Mar 13 2012 13:21:33 with gcc 4.3.2
  configuration: --cc=/usr/local/gcc-4.3.2/bin/gcc --enable-gpl
  libavutil      51. 42.100 / 51. 42.100
  libavcodec     54. 10.100 / 54. 10.100
  libavformat    54.  2.100 / 54.  2.100
  libavdevice    53.  4.100 / 53.  4.100
  libavfilter     2. 64.101 /  2. 64.101
  libswscale      2.  1.100 /  2.  1.100
  libswresample   0.  7.100 /  0.  7.100
  libpostproc    52.  0.100 / 52.  0.100

Program received signal SIGFPE, Arithmetic exception.
[Switching to Thread 0xb7c056c0 (LWP 25589)]
0x0819f5a7 in aiff_read_header (s=0x8eb6aa0) at libavformat/aiffdec.c:162
162         codec->bit_rate = codec->sample_rate * (codec->block_align << 3) /
(gdb) bt
#0  0x0819f5a7 in aiff_read_header (s=0x8eb6aa0) at libavformat/aiffdec.c:162
#1  0x08188146 in avformat_open_input (ps=0xbf805764,
    filename=0xbf807283 "out.aiff", fmt=0x0, options=0x8df766c)
    at libavformat/utils.c:622
#2  0x080535ab in opt_input_file (o=0xbf805848, opt=0xbf807281 "i",
    filename=0xbf807283 "out.aiff") at ffmpeg.c:3691
#3  0x0805ef12 in parse_option (optctx=0xbf805848, opt=0xbf807281 "i",
    arg=0xbf807283 "out.aiff", options=0x87c9fc0) at cmdutils.c:300
#4  0x0805f2a3 in parse_options (optctx=0xbf805848, argc=3, argv=0xbf805a84,
    options=0x87c9fc0, parse_arg_function=0x8059b50 <opt_output_file>)
    at cmdutils.c:333
#5  0x08058dc6 in main (argc=3, argv=0xbf805a84) at ffmpeg.c:5151

comment:2 Changed 5 years ago by cehoyos

Please consider sending patches to ffmpeg-devel, they get more attention there.

comment:3 Changed 5 years ago by cehoyos

  • Resolution set to fixed
  • Status changed from open to closed

Fixed by Thomas Tomas Härdin with a mostly identical patch.

comment:4 Changed 4 years ago by cehoyos

  • Keywords aif added; aiff removed
Note: See TracTickets for help on using tickets.