libavformat/oggparseflac.c:77: error: Integer Overflow L2
  ([0, +oo] - 4):unsigned32.

libavformat/oggparseflac.c:44:5: <LHS trace>
42.         return 0;
43. 
44.     bitstream_init8(&bc, os->buf + os->pstart, os->psize);
        ^
45.     bitstream_skip(&bc, 1); /* metadata_last */
46.     mdt = bitstream_read(&bc, 7);

libavformat/oggparseflac.c:44:5: Call
42.         return 0;
43. 
44.     bitstream_init8(&bc, os->buf + os->pstart, os->psize);
        ^
45.     bitstream_skip(&bc, 1); /* metadata_last */
46.     mdt = bitstream_read(&bc, 7);

libavcodec/bitstream.h:103:1: Parameter `*buffer`
  101. 
  102. /* Initialize BitstreamContext with buffer size in bytes instead of bits. */
  103. static inline int bitstream_init8(BitstreamContext *bc, const uint8_t *buffer,
       ^
  104.                                   unsigned byte_size)
  105. {

libavformat/oggparseflac.c:45:5: Call
43. 
44.     bitstream_init8(&bc, os->buf + os->pstart, os->psize);
45.     bitstream_skip(&bc, 1); /* metadata_last */
        ^
46.     mdt = bitstream_read(&bc, 7);
47. 

libavcodec/bitstream.h:240:1: Parameter `*bc->ptr`
  238. 
  239. /* Skip n bits in the buffer. */
  240. static inline void bitstream_skip(BitstreamContext *bc, unsigned n)
       ^
  241. {
  242.     if (n < bc->bits_left)

libavformat/oggparseflac.c:77:9: Binary operation: ([0, +oo] - 4):unsigned32
75.         avpriv_set_pts_info(st, 64, 1, samplerate);
76.     } else if (mdt == FLAC_METADATA_TYPE_VORBIS_COMMENT) {
77.         ff_vorbis_stream_comment(s, st, os->buf + os->pstart + 4, os->psize - 4);
            ^
78.     }
79. 

static int
flac_header (AVFormatContext * s, int idx)
{
    struct ogg *ogg = s->priv_data;
    struct ogg_stream *os = ogg->streams + idx;
    AVStream *st = s->streams[idx];
    BitstreamContext bc;
    int mdt;
    if (os->buf[os->pstart] == 0xff)
        return 0;
    bitstream_init8(&bc, os->buf + os->pstart, os->psize);
    bitstream_skip(&bc, 1);
    mdt = bitstream_read(&bc, 7);
    if (mdt == OGG_FLAC_METADATA_TYPE_STREAMINFO) {
        uint8_t *streaminfo_start = os->buf + os->pstart + 5 + 4 + 4 + 4;
        uint32_t samplerate;
        bitstream_skip(&bc, 4 * 8);
        if (bitstream_read(&bc, 8) != 1)
            return -1;
        bitstream_skip(&bc, 8 + 16);
        bitstream_skip(&bc, 4 * 8);
        if (bitstream_read(&bc, 32) != FLAC_STREAMINFO_SIZE)
            return -1;
        st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
        st->codecpar->codec_id = AV_CODEC_ID_FLAC;
        st->need_parsing = AVSTREAM_PARSE_HEADERS;
        st->codecpar->extradata =
            av_malloc(FLAC_STREAMINFO_SIZE + AV_INPUT_BUFFER_PADDING_SIZE);
        memcpy(st->codecpar->extradata, streaminfo_start, FLAC_STREAMINFO_SIZE);
        st->codecpar->extradata_size = FLAC_STREAMINFO_SIZE;
        samplerate = AV_RB24(st->codecpar->extradata + 10) >> 4;
        if (!samplerate)
            return AVERROR_INVALIDDATA;
        avpriv_set_pts_info(st, 64, 1, samplerate);
    } else if (mdt == FLAC_METADATA_TYPE_VORBIS_COMMENT) {
        ff_vorbis_stream_comment(s, st, os->buf + os->pstart + 4, os->psize - 4);
    }
    return 1;
}
['static int\nflac_header (AVFormatContext * s, int idx)\n{\n    struct ogg *ogg = s->priv_data;\n    struct ogg_stream *os = ogg->streams + idx;\n    AVStream *st = s->streams[idx];\n    BitstreamContext bc;\n    int mdt;\n    if (os->buf[os->pstart] == 0xff)\n        return 0;\n    bitstream_init8(&bc, os->buf + os->pstart, os->psize);\n    bitstream_skip(&bc, 1);\n    mdt = bitstream_read(&bc, 7);\n    if (mdt == OGG_FLAC_METADATA_TYPE_STREAMINFO) {\n        uint8_t *streaminfo_start = os->buf + os->pstart + 5 + 4 + 4 + 4;\n        uint32_t samplerate;\n        bitstream_skip(&bc, 4 * 8);\n        if (bitstream_read(&bc, 8) != 1)\n            return -1;\n        bitstream_skip(&bc, 8 + 16);\n        bitstream_skip(&bc, 4 * 8);\n        if (bitstream_read(&bc, 32) != FLAC_STREAMINFO_SIZE)\n            return -1;\n        st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;\n        st->codecpar->codec_id = AV_CODEC_ID_FLAC;\n        st->need_parsing = AVSTREAM_PARSE_HEADERS;\n        st->codecpar->extradata =\n            av_malloc(FLAC_STREAMINFO_SIZE + AV_INPUT_BUFFER_PADDING_SIZE);\n        memcpy(st->codecpar->extradata, streaminfo_start, FLAC_STREAMINFO_SIZE);\n        st->codecpar->extradata_size = FLAC_STREAMINFO_SIZE;\n        samplerate = AV_RB24(st->codecpar->extradata + 10) >> 4;\n        if (!samplerate)\n            return AVERROR_INVALIDDATA;\n        avpriv_set_pts_info(st, 64, 1, samplerate);\n    } else if (mdt == FLAC_METADATA_TYPE_VORBIS_COMMENT) {\n        ff_vorbis_stream_comment(s, st, os->buf + os->pstart + 4, os->psize - 4);\n    }\n    return 1;\n}', 'static inline int bitstream_init8(BitstreamContext *bc, const uint8_t *buffer,\n                                  unsigned byte_size)\n{\n    if (byte_size > INT_MAX / 8)\n        return AVERROR_INVALIDDATA;\n    return bitstream_init(bc, buffer, byte_size * 8);\n}', 'static inline void bitstream_skip(BitstreamContext *bc, unsigned n)\n{\n    if (n < bc->bits_left)\n        skip_remaining(bc, n);\n    else {\n        n -= bc->bits_left;\n        bc->bits      = 0;\n        bc->bits_left = 0;\n        if (n >= 64) {\n            unsigned skip = n / 8;\n            n -= skip * 8;\n            bc->ptr += skip;\n        }\n        refill_64(bc);\n        if (n)\n            skip_remaining(bc, n);\n    }\n}']