summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark H Weaver <mhw@netris.org>2015-07-21 01:49:43 -0400
committerMark H Weaver <mhw@netris.org>2015-07-21 02:05:20 -0400
commitc0eac5a86246a2c8eb4fe3177a64cfc9687cf5e0 (patch)
treeef31bdae1d9aa09f3b99887c3523aee644aeaf25
parent4d85391059604959a010c39953bea5c62f52dc90 (diff)
gnu: libmad: Apply fixes for ARMv7 Thumb, etc.
* gnu/packages/patches/libmad-armv7-thumb-pt1.patch, gnu/packages/patches/libmad-armv7-thumb-pt2.patch, gnu/packages/patches/libmad-frame-length.patch: New files. * gnu-system.am (dist_patch_DATA): Add them. * gnu/packages/mp3.scm (libmad)[source]: Add patches.
-rw-r--r--gnu-system.am3
-rw-r--r--gnu/packages/mp3.scm6
-rw-r--r--gnu/packages/patches/libmad-armv7-thumb-pt1.patch16
-rw-r--r--gnu/packages/patches/libmad-armv7-thumb-pt2.patch36
-rw-r--r--gnu/packages/patches/libmad-frame-length.patch199
5 files changed, 259 insertions, 1 deletions
diff --git a/gnu-system.am b/gnu-system.am
index 2c361f2f1a5..6302d22377d 100644
--- a/gnu-system.am
+++ b/gnu-system.am
@@ -489,6 +489,9 @@ dist_patch_DATA = \
489 gnu/packages/patches/libcanberra-sound-theme-freedesktop.patch \ 489 gnu/packages/patches/libcanberra-sound-theme-freedesktop.patch \
490 gnu/packages/patches/libevent-dns-tests.patch \ 490 gnu/packages/patches/libevent-dns-tests.patch \
491 gnu/packages/patches/liboop-mips64-deplibs-fix.patch \ 491 gnu/packages/patches/liboop-mips64-deplibs-fix.patch \
492 gnu/packages/patches/libmad-armv7-thumb-pt1.patch \
493 gnu/packages/patches/libmad-armv7-thumb-pt2.patch \
494 gnu/packages/patches/libmad-frame-length.patch \
492 gnu/packages/patches/libmad-mips-newgcc.patch \ 495 gnu/packages/patches/libmad-mips-newgcc.patch \
493 gnu/packages/patches/libtheora-config-guess.patch \ 496 gnu/packages/patches/libtheora-config-guess.patch \
494 gnu/packages/patches/libtiff-CVE-2012-4564.patch \ 497 gnu/packages/patches/libtiff-CVE-2012-4564.patch \
diff --git a/gnu/packages/mp3.scm b/gnu/packages/mp3.scm
index 163e075f181..77eae655844 100644
--- a/gnu/packages/mp3.scm
+++ b/gnu/packages/mp3.scm
@@ -1,6 +1,7 @@
1;;; GNU Guix --- Functional package management for GNU 1;;; GNU Guix --- Functional package management for GNU
2;;; Copyright © 2013 Andreas Enge <andreas@enge.fr> 2;;; Copyright © 2013 Andreas Enge <andreas@enge.fr>
3;;; Copyright © 2014, 2015 Ludovic Courtès <ludo@gnu.org> 3;;; Copyright © 2014, 2015 Ludovic Courtès <ludo@gnu.org>
4;;; Copyright © 2015 Mark H Weaver <mhw@netris.org>
4;;; 5;;;
5;;; This file is part of GNU Guix. 6;;; This file is part of GNU Guix.
6;;; 7;;;
@@ -52,7 +53,10 @@
52 (sha256 53 (sha256
53 (base32 54 (base32
54 "14460zhacxhswnzb36qfpd1f2wbk10qvksvm6wyq5hpvdgnw7ymv")) 55 "14460zhacxhswnzb36qfpd1f2wbk10qvksvm6wyq5hpvdgnw7ymv"))
55 (patches (list (search-patch "libmad-mips-newgcc.patch"))))) 56 (patches (map search-patch '("libmad-armv7-thumb-pt1.patch"
57 "libmad-armv7-thumb-pt2.patch"
58 "libmad-frame-length.patch"
59 "libmad-mips-newgcc.patch")))))
56 (build-system gnu-build-system) 60 (build-system gnu-build-system)
57 (arguments 61 (arguments
58 `(#:phases 62 `(#:phases
diff --git a/gnu/packages/patches/libmad-armv7-thumb-pt1.patch b/gnu/packages/patches/libmad-armv7-thumb-pt1.patch
new file mode 100644
index 00000000000..86339ddad8c
--- /dev/null
+++ b/gnu/packages/patches/libmad-armv7-thumb-pt1.patch
@@ -0,0 +1,16 @@
1Copied from Debian.
2
3From: Konstantinos Margaritis <markos@debian.org>
4Subject: use "adr" instead of "add" to make code ready for thumb2
5
6--- ./imdct_l_arm.S.orig 2010-02-25 13:25:23.000000000 +0100
7+++ ./imdct_l_arm.S 2010-02-25 13:27:26.000000000 +0100
8@@ -468,7 +468,7 @@
9
10 @----
11
12- add r2, pc, #(imdct36_long_karray-.-8) @ r2 = base address of Knn array (PIC safe ?)
13+ adr r2, imdct36_long_karray
14
15
16 loop:
diff --git a/gnu/packages/patches/libmad-armv7-thumb-pt2.patch b/gnu/packages/patches/libmad-armv7-thumb-pt2.patch
new file mode 100644
index 00000000000..bb450967e67
--- /dev/null
+++ b/gnu/packages/patches/libmad-armv7-thumb-pt2.patch
@@ -0,0 +1,36 @@
1Copied from Debian.
2
3From: Dave Martin
4Subject: "rsc" doesnt exist anymore in thumb2
5
6diff --git a/fixed.h b/fixed.h
7index 4b58abf..ba4bc26 100644
8--- a/fixed.h
9+++ b/fixed.h
10@@ -275,12 +275,25 @@ mad_fixed_t mad_f_mul_inline(mad_fixed_t x, mad_fixed_t y)
11 : "+r" (lo), "+r" (hi) \
12 : "%r" (x), "r" (y))
13
14+#ifdef __thumb__
15+/* In Thumb-2, the RSB-immediate instruction is only allowed with a zero
16+ operand. If needed this code can also support Thumb-1
17+ (simply append "s" to the end of the second two instructions). */
18+# define MAD_F_MLN(hi, lo) \
19+ asm ("rsbs %0, %0, #0\n\t" \
20+ "sbc %1, %1, %1\n\t" \
21+ "sub %1, %1, %2" \
22+ : "+&r" (lo), "=&r" (hi) \
23+ : "r" (hi) \
24+ : "cc")
25+#else /* ! __thumb__ */
26 # define MAD_F_MLN(hi, lo) \
27 asm ("rsbs %0, %2, #0\n\t" \
28 "rsc %1, %3, #0" \
29- : "=r" (lo), "=r" (hi) \
30+ : "=&r" (lo), "=r" (hi) \
31 : "0" (lo), "1" (hi) \
32 : "cc")
33+#endif /* __thumb__ */
34
35 # define mad_f_scale64(hi, lo) \
36 ({ mad_fixed_t __result; \
diff --git a/gnu/packages/patches/libmad-frame-length.patch b/gnu/packages/patches/libmad-frame-length.patch
new file mode 100644
index 00000000000..3434eba5777
--- /dev/null
+++ b/gnu/packages/patches/libmad-frame-length.patch
@@ -0,0 +1,199 @@
1Copied from Debian.
2
3; You can calculate where the next frame will start depending on things
4; like the bitrate. See mad_header_decode(). It seems that when decoding
5; the frame you can go past that boundary. This attempts to catch those cases,
6; but might not catch all of them.
7; For more info see http://bugs.debian.org/508133
8Index: libmad-0.15.1b/layer12.c
9===================================================================
10--- libmad-0.15.1b.orig/layer12.c 2008-12-23 21:38:07.000000000 +0100
11+++ libmad-0.15.1b/layer12.c 2008-12-23 21:38:12.000000000 +0100
12@@ -134,6 +134,12 @@
13 for (sb = 0; sb < bound; ++sb) {
14 for (ch = 0; ch < nch; ++ch) {
15 nb = mad_bit_read(&stream->ptr, 4);
16+ if (mad_bit_nextbyte(&stream->ptr) > stream->next_frame)
17+ {
18+ stream->error = MAD_ERROR_LOSTSYNC;
19+ stream->sync = 0;
20+ return -1;
21+ }
22
23 if (nb == 15) {
24 stream->error = MAD_ERROR_BADBITALLOC;
25@@ -146,6 +152,12 @@
26
27 for (sb = bound; sb < 32; ++sb) {
28 nb = mad_bit_read(&stream->ptr, 4);
29+ if (mad_bit_nextbyte(&stream->ptr) > stream->next_frame)
30+ {
31+ stream->error = MAD_ERROR_LOSTSYNC;
32+ stream->sync = 0;
33+ return -1;
34+ }
35
36 if (nb == 15) {
37 stream->error = MAD_ERROR_BADBITALLOC;
38@@ -162,6 +174,12 @@
39 for (ch = 0; ch < nch; ++ch) {
40 if (allocation[ch][sb]) {
41 scalefactor[ch][sb] = mad_bit_read(&stream->ptr, 6);
42+ if (mad_bit_nextbyte(&stream->ptr) > stream->next_frame)
43+ {
44+ stream->error = MAD_ERROR_LOSTSYNC;
45+ stream->sync = 0;
46+ return -1;
47+ }
48
49 # if defined(OPT_STRICT)
50 /*
51@@ -187,6 +205,12 @@
52 frame->sbsample[ch][s][sb] = nb ?
53 mad_f_mul(I_sample(&stream->ptr, nb),
54 sf_table[scalefactor[ch][sb]]) : 0;
55+ if (mad_bit_nextbyte(&stream->ptr) > stream->next_frame)
56+ {
57+ stream->error = MAD_ERROR_LOSTSYNC;
58+ stream->sync = 0;
59+ return -1;
60+ }
61 }
62 }
63
64@@ -195,6 +219,12 @@
65 mad_fixed_t sample;
66
67 sample = I_sample(&stream->ptr, nb);
68+ if (mad_bit_nextbyte(&stream->ptr) > stream->next_frame)
69+ {
70+ stream->error = MAD_ERROR_LOSTSYNC;
71+ stream->sync = 0;
72+ return -1;
73+ }
74
75 for (ch = 0; ch < nch; ++ch) {
76 frame->sbsample[ch][s][sb] =
77@@ -403,7 +433,15 @@
78 nbal = bitalloc_table[offsets[sb]].nbal;
79
80 for (ch = 0; ch < nch; ++ch)
81+ {
82 allocation[ch][sb] = mad_bit_read(&stream->ptr, nbal);
83+ if (mad_bit_nextbyte(&stream->ptr) > stream->next_frame)
84+ {
85+ stream->error = MAD_ERROR_LOSTSYNC;
86+ stream->sync = 0;
87+ return -1;
88+ }
89+ }
90 }
91
92 for (sb = bound; sb < sblimit; ++sb) {
93@@ -411,6 +449,13 @@
94
95 allocation[0][sb] =
96 allocation[1][sb] = mad_bit_read(&stream->ptr, nbal);
97+
98+ if (mad_bit_nextbyte(&stream->ptr) > stream->next_frame)
99+ {
100+ stream->error = MAD_ERROR_LOSTSYNC;
101+ stream->sync = 0;
102+ return -1;
103+ }
104 }
105
106 /* decode scalefactor selection info */
107@@ -419,6 +464,12 @@
108 for (ch = 0; ch < nch; ++ch) {
109 if (allocation[ch][sb])
110 scfsi[ch][sb] = mad_bit_read(&stream->ptr, 2);
111+ if (mad_bit_nextbyte(&stream->ptr) > stream->next_frame)
112+ {
113+ stream->error = MAD_ERROR_LOSTSYNC;
114+ stream->sync = 0;
115+ return -1;
116+ }
117 }
118 }
119
120@@ -442,6 +493,12 @@
121 for (ch = 0; ch < nch; ++ch) {
122 if (allocation[ch][sb]) {
123 scalefactor[ch][sb][0] = mad_bit_read(&stream->ptr, 6);
124+ if (mad_bit_nextbyte(&stream->ptr) > stream->next_frame)
125+ {
126+ stream->error = MAD_ERROR_LOSTSYNC;
127+ stream->sync = 0;
128+ return -1;
129+ }
130
131 switch (scfsi[ch][sb]) {
132 case 2:
133@@ -452,11 +509,23 @@
134
135 case 0:
136 scalefactor[ch][sb][1] = mad_bit_read(&stream->ptr, 6);
137+ if (mad_bit_nextbyte(&stream->ptr) > stream->next_frame)
138+ {
139+ stream->error = MAD_ERROR_LOSTSYNC;
140+ stream->sync = 0;
141+ return -1;
142+ }
143 /* fall through */
144
145 case 1:
146 case 3:
147 scalefactor[ch][sb][2] = mad_bit_read(&stream->ptr, 6);
148+ if (mad_bit_nextbyte(&stream->ptr) > stream->next_frame)
149+ {
150+ stream->error = MAD_ERROR_LOSTSYNC;
151+ stream->sync = 0;
152+ return -1;
153+ }
154 }
155
156 if (scfsi[ch][sb] & 1)
157@@ -488,6 +557,12 @@
158 index = offset_table[bitalloc_table[offsets[sb]].offset][index - 1];
159
160 II_samples(&stream->ptr, &qc_table[index], samples);
161+ if (mad_bit_nextbyte(&stream->ptr) > stream->next_frame)
162+ {
163+ stream->error = MAD_ERROR_LOSTSYNC;
164+ stream->sync = 0;
165+ return -1;
166+ }
167
168 for (s = 0; s < 3; ++s) {
169 frame->sbsample[ch][3 * gr + s][sb] =
170@@ -506,6 +581,12 @@
171 index = offset_table[bitalloc_table[offsets[sb]].offset][index - 1];
172
173 II_samples(&stream->ptr, &qc_table[index], samples);
174+ if (mad_bit_nextbyte(&stream->ptr) > stream->next_frame)
175+ {
176+ stream->error = MAD_ERROR_LOSTSYNC;
177+ stream->sync = 0;
178+ return -1;
179+ }
180
181 for (ch = 0; ch < nch; ++ch) {
182 for (s = 0; s < 3; ++s) {
183Index: libmad-0.15.1b/layer3.c
184===================================================================
185--- libmad-0.15.1b.orig/layer3.c 2008-12-23 21:38:07.000000000 +0100
186+++ libmad-0.15.1b/layer3.c 2008-12-23 21:38:12.000000000 +0100
187@@ -2608,6 +2608,12 @@
188 next_md_begin = 0;
189
190 md_len = si.main_data_begin + frame_space - next_md_begin;
191+ if (md_len + MAD_BUFFER_GUARD > MAD_BUFFER_MDLEN)
192+ {
193+ stream->error = MAD_ERROR_LOSTSYNC;
194+ stream->sync = 0;
195+ return -1;
196+ }
197
198 frame_used = 0;
199