summaryrefslogtreecommitdiffstats
path: root/src/libdca-5-avoid-crashing-with-invalid-frames.patch
blob: cd144445d7b925a9af1e254c9b66010a621c3184 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
This file is part of MXE.
See index.html for further information.

Taken from libdca svn: svn://svn.videolan.org/libdca/trunk.

r89 | sam | 2008-07-19 22:26:17 +0000 (Sat, 19 Jul 2008) | 2 lines
  * parse.c: avoid crashing with invalid frames setting a bitalloc_huffman
    component to 7.

--- libdca.orig/libdca/parse.c
+++ libdca/libdca/parse.c
@@ -364,7 +364,10 @@
     for (i = 0; i < state->prim_channels; i++)
     {
         state->bitalloc_huffman[i] = bitstream_get (state, 3);
-        /* if (state->bitalloc_huffman[i] == 7) bailout */
+        /* There might be a way not to trash the whole frame, but for
+         * now we must bail out or we will buffer overflow later. */
+        if (state->bitalloc_huffman[i] == 7)
+            return 1;
 #ifdef DEBUG
         fprintf (stderr, "bit allocation quantizer: %i\n",
                  state->bitalloc_huffman[i]);
@@ -541,6 +544,7 @@
                 k < state->vq_start_subband[j] &&
                 state->bitalloc[j][k] > 0)
             {
+                /* tmode cannot overflow since transient_huffman[j] < 4 */
                 state->transition_mode[j][k] = InverseQ (state,
                     tmode[state->transient_huffman[j]]);
             }