mxe/src/libdca-3-sanity-check-for-s...

28 lines
882 B
Diff

This file is part of MXE.
See index.html for further information.
Taken from libdca svn: svn://svn.videolan.org/libdca/trunk.
r87 | sam | 2008-07-18 19:22:47 +0000 (Fri, 18 Jul 2008) | 2 lines
* parse.c: sanity check for subframes and prim_channels to avoid crashes
with invalid streams.
--- libdca.orig/libdca/parse.c
+++ libdca/libdca/parse.c
@@ -305,8 +305,15 @@
/* Primary audio coding header */
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;
+ if (state->prim_channels > DCA_PRIM_CHANNELS_MAX)
+ state->prim_channels = DCA_PRIM_CHANNELS_MAX;
+
#ifdef DEBUG
fprintf (stderr, "subframes: %i\n", state->subframes);
fprintf (stderr, "prim channels: %i\n", state->prim_channels);