Commit 38a4a894 authored by Sam Hocevar's avatar Sam Hocevar

* parse.c: sanity check for subframes and prim_channels to avoid crashes

    with invalid streams.
parent 6d22c4e0
...@@ -305,8 +305,15 @@ int dca_frame (dca_state_t * state, uint8_t * buf, int * flags, ...@@ -305,8 +305,15 @@ int dca_frame (dca_state_t * state, uint8_t * buf, int * flags,
/* Primary audio coding header */ /* Primary audio coding header */
state->subframes = bitstream_get (state, 4) + 1; state->subframes = bitstream_get (state, 4) + 1;
if (state->subframes > DCA_SUBFRAMES_MAX)
state->subframes = DCA_SUBFRAMES_MAX;
state->prim_channels = bitstream_get (state, 3) + 1; state->prim_channels = bitstream_get (state, 3) + 1;
if (state->prim_channels > DCA_PRIM_CHANNELS_MAX)
state->prim_channels = DCA_PRIM_CHANNELS_MAX;
#ifdef DEBUG #ifdef DEBUG
fprintf (stderr, "subframes: %i\n", state->subframes); fprintf (stderr, "subframes: %i\n", state->subframes);
fprintf (stderr, "prim channels: %i\n", state->prim_channels); fprintf (stderr, "prim channels: %i\n", state->prim_channels);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment