1 |
commit: 8d48df85c8d347bbb01159a673b9b78cb6f2f44d |
2 |
Author: David Seifert <soap <AT> gentoo <DOT> org> |
3 |
AuthorDate: Wed Sep 9 10:59:10 2020 +0000 |
4 |
Commit: David Seifert <soap <AT> gentoo <DOT> org> |
5 |
CommitDate: Wed Sep 9 10:59:10 2020 +0000 |
6 |
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=8d48df85 |
7 |
|
8 |
media-libs/libsndfile: Add patch for pointer aliasing |
9 |
|
10 |
Bug: https://bugs.gentoo.org/719020 |
11 |
Fixes: erikd/libsndfile#581 |
12 |
Package-Manager: Portage-3.0.6, Repoman-3.0.1 |
13 |
Signed-off-by: David Seifert <soap <AT> gentoo.org> |
14 |
|
15 |
.../files/libsndfile-1.0.29-pointer-aliasing.patch | 128 +++++++++++++++++++++ |
16 |
media-libs/libsndfile/libsndfile-1.0.29.ebuild | 5 + |
17 |
2 files changed, 133 insertions(+) |
18 |
|
19 |
diff --git a/media-libs/libsndfile/files/libsndfile-1.0.29-pointer-aliasing.patch b/media-libs/libsndfile/files/libsndfile-1.0.29-pointer-aliasing.patch |
20 |
new file mode 100644 |
21 |
index 00000000000..644bf333413 |
22 |
--- /dev/null |
23 |
+++ b/media-libs/libsndfile/files/libsndfile-1.0.29-pointer-aliasing.patch |
24 |
@@ -0,0 +1,128 @@ |
25 |
+From e5f9469a824fc660494b52ec3edc0dda2509594c Mon Sep 17 00:00:00 2001 |
26 |
+From: Arthur Taylor <art@×××××.ca> |
27 |
+Date: Tue, 8 Sep 2020 09:31:37 -0700 |
28 |
+Subject: [PATCH] Opus: Fix integer bug in header parsing. Fixes issue #581. |
29 |
+ |
30 |
+Fix errors in parsing an OggOpus header packet where aliased pointers of |
31 |
+different type widths are used with psf_binheader_readf(), resulting in |
32 |
+incorrect data or endian issues. Telling psf_binheader_readf() to read |
33 |
+an integer of fixed width, but then passing a pointer to an integer |
34 |
+of a different width is a bug. |
35 |
+--- |
36 |
+ src/ogg_opus.c | 38 ++++++++++++++++++++++---------------- |
37 |
+ 1 file changed, 22 insertions(+), 16 deletions(-) |
38 |
+ |
39 |
+diff --git a/src/ogg_opus.c b/src/ogg_opus.c |
40 |
+index de66b061..b40a6fb1 100644 |
41 |
+--- a/src/ogg_opus.c |
42 |
++++ b/src/ogg_opus.c |
43 |
+@@ -183,32 +183,32 @@ |
44 |
+ #define OGG_OPUS_PREROLL (80 * 48) /* 80 milliseconds */ |
45 |
+ |
46 |
+ typedef struct |
47 |
+-{ int version ; |
48 |
++{ uint8_t version ; |
49 |
+ |
50 |
+ /* Number of channels, 1...255 */ |
51 |
+- int channels ; |
52 |
++ uint8_t channels ; |
53 |
+ |
54 |
+ /* Encoder latency, the amount to skip before valid data comes out. */ |
55 |
+- int preskip ; |
56 |
++ uint16_t preskip ; |
57 |
+ |
58 |
+ /* The sample rate of a the encoded source, as it may have been converted. */ |
59 |
+- int input_samplerate ; |
60 |
++ int32_t input_samplerate ; |
61 |
+ |
62 |
+ /* 'baked-in' gain to apply, dB S7.8 format. Should be zero when possible. */ |
63 |
+ int16_t gain ; |
64 |
+ |
65 |
+ /* Channel mapping type. See OggOpus spec */ |
66 |
+- int channel_mapping ; |
67 |
++ uint8_t channel_mapping ; |
68 |
+ |
69 |
+ /* The rest is only used if channel_mapping != 0 */ |
70 |
+ /* How many streams are there? */ |
71 |
+- int nb_streams ; |
72 |
++ uint8_t nb_streams ; |
73 |
+ |
74 |
+ /* How man of those streams are coupled? (aka stereo) */ |
75 |
+- int nb_coupled ; |
76 |
++ uint8_t nb_coupled ; |
77 |
+ |
78 |
+ /* Mapping of opus streams to output channels */ |
79 |
+- unsigned char stream_map [255] ; |
80 |
++ uint8_t stream_map [255] ; |
81 |
+ } OpusHeader ; |
82 |
+ |
83 |
+ typedef struct |
84 |
+@@ -637,6 +637,9 @@ ogg_opus_setup_decoder (SF_PRIVATE *psf, int input_samplerate) |
85 |
+ static int |
86 |
+ ogg_opus_setup_encoder (SF_PRIVATE *psf, OGG_PRIVATE *odata, OPUS_PRIVATE *oopus) |
87 |
+ { int error ; |
88 |
++ int lookahead ; |
89 |
++ int nb_streams ; |
90 |
++ int nb_coupled ; |
91 |
+ |
92 |
+ /* default page latency value (1000ms) */ |
93 |
+ oopus->u.encode.latency = 1000 * 48 ; |
94 |
+@@ -655,16 +658,16 @@ ogg_opus_setup_encoder (SF_PRIVATE *psf, OGG_PRIVATE *odata, OPUS_PRIVATE *oopus |
95 |
+ |
96 |
+ if (psf->sf.channels <= 2) |
97 |
+ { oopus->header.channel_mapping = 0 ; |
98 |
+- oopus->header.nb_streams = 1 ; |
99 |
+- oopus->header.nb_coupled = psf->sf.channels - 1 ; |
100 |
++ nb_streams = 1 ; |
101 |
++ nb_coupled = psf->sf.channels - 1 ; |
102 |
+ oopus->header.stream_map [0] = 0 ; |
103 |
+ oopus->header.stream_map [1] = 1 ; |
104 |
+ |
105 |
+ oopus->u.encode.state = opus_multistream_encoder_create ( |
106 |
+ psf->sf.samplerate, |
107 |
+ psf->sf.channels, |
108 |
+- oopus->header.nb_streams, |
109 |
+- oopus->header.nb_coupled, |
110 |
++ nb_streams, |
111 |
++ nb_coupled, |
112 |
+ oopus->header.stream_map, |
113 |
+ OPUS_APPLICATION_AUDIO, |
114 |
+ &error) ; |
115 |
+@@ -683,17 +686,20 @@ ogg_opus_setup_encoder (SF_PRIVATE *psf, OGG_PRIVATE *odata, OPUS_PRIVATE *oopus |
116 |
+ psf->sf.samplerate, |
117 |
+ psf->sf.channels, |
118 |
+ oopus->header.channel_mapping, |
119 |
+- &oopus->header.nb_streams, |
120 |
+- &oopus->header.nb_coupled, |
121 |
++ &nb_streams, |
122 |
++ &nb_coupled, |
123 |
+ oopus->header.stream_map, |
124 |
+ OPUS_APPLICATION_AUDIO, |
125 |
+ &error) ; |
126 |
++ |
127 |
+ } |
128 |
+ |
129 |
+ if (error != OPUS_OK) |
130 |
+ { psf_log_printf (psf, "Opus : Error, opus_multistream_encoder_create returned %s\n", opus_strerror (error)) ; |
131 |
+ return SFE_BAD_OPEN_FORMAT ; |
132 |
+ } ; |
133 |
++ oopus->header.nb_streams = nb_streams ; |
134 |
++ oopus->header.nb_coupled = nb_coupled ; |
135 |
+ |
136 |
+ opus_multistream_encoder_ctl (oopus->u.encode.state, OPUS_GET_BITRATE (&oopus->u.encode.bitrate)) ; |
137 |
+ psf_log_printf (psf, "Encoding at target bitrate of %dbps\n", oopus->u.encode.bitrate) ; |
138 |
+@@ -711,12 +717,12 @@ ogg_opus_setup_encoder (SF_PRIVATE *psf, OGG_PRIVATE *odata, OPUS_PRIVATE *oopus |
139 |
+ ** GOTCHA: This returns the preskip at the encoder samplerate, not the |
140 |
+ ** granulepos rate of 48000Hz needed for header.preskip. |
141 |
+ */ |
142 |
+- error = opus_multistream_encoder_ctl (oopus->u.encode.state, OPUS_GET_LOOKAHEAD (&oopus->header.preskip)) ; |
143 |
++ error = opus_multistream_encoder_ctl (oopus->u.encode.state, OPUS_GET_LOOKAHEAD (&lookahead)) ; |
144 |
+ if (error != OPUS_OK) |
145 |
+ { psf_log_printf (psf, "Opus : OPUS_GET_LOOKAHEAD returned: %s\n", opus_strerror (error)) ; |
146 |
+ return SFE_BAD_OPEN_FORMAT ; |
147 |
+ } ; |
148 |
+- oopus->header.preskip *= oopus->sr_factor ; |
149 |
++ oopus->header.preskip = lookahead * oopus->sr_factor ; |
150 |
+ |
151 |
+ oopus->len = OGG_OPUS_ENCODE_PACKET_LEN (psf->sf.samplerate) ; |
152 |
+ oopus->buffer = malloc (sizeof (float) * psf->sf.channels * oopus->len) ; |
153 |
|
154 |
diff --git a/media-libs/libsndfile/libsndfile-1.0.29.ebuild b/media-libs/libsndfile/libsndfile-1.0.29.ebuild |
155 |
index d975b6e0270..37cae9590d1 100644 |
156 |
--- a/media-libs/libsndfile/libsndfile-1.0.29.ebuild |
157 |
+++ b/media-libs/libsndfile/libsndfile-1.0.29.ebuild |
158 |
@@ -42,6 +42,11 @@ if [[ ${PV} == *9999 ]]; then |
159 |
" |
160 |
fi |
161 |
|
162 |
+PATCHES=( |
163 |
+ # bug 719020: backported, remove on version bump |
164 |
+ "${FILESDIR}"/${P}-pointer-aliasing.patch |
165 |
+) |
166 |
+ |
167 |
pkg_setup() { |
168 |
if use test || [[ ${PV} == *9999 ]]; then |
169 |
python-any-r1_pkg_setup |