libdca (0.0.5-5) r87-sanity-check-for-subframes-and-prim_channels.patch

Summary

 libdca/parse.c |    7 +++++++
 1 file changed, 7 insertions(+)

    
download this patch

Patch contents

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);