db-move: moved epiphany from [testing] to [extra] (x86_64)
[arch-packages.git] / audiofile / trunk / 03_CVE-2015-7747.patch
blob3325639591060d3fd087b5099827c9684fb25fb2
1 Description: fix buffer overflow when changing both sample format and
2 number of channels
3 Origin: https://github.com/mpruett/audiofile/pull/25
4 Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/audiofile/+bug/1502721
5 Bug-Debian: https://bugs.debian.org/801102
7 --- a/libaudiofile/modules/ModuleState.cpp
8 +++ b/libaudiofile/modules/ModuleState.cpp
9 @@ -402,7 +402,7 @@ status ModuleState::arrange(AFfilehandle
10 addModule(new Transform(outfc, in.pcm, out.pcm));
12 if (in.channelCount != out.channelCount)
13 - addModule(new ApplyChannelMatrix(infc, isReading,
14 + addModule(new ApplyChannelMatrix(outfc, isReading,
15 in.channelCount, out.channelCount,
16 in.pcm.minClip, in.pcm.maxClip,
17 track->channelMatrix));
18 --- a/test/Makefile.am
19 +++ b/test/Makefile.am
20 @@ -26,6 +26,7 @@ TESTS = \
21 VirtualFile \
22 floatto24 \
23 query2 \
24 + sixteen-stereo-to-eight-mono \
25 sixteen-to-eight \
26 testchannelmatrix \
27 testdouble \
28 @@ -139,6 +140,7 @@ printmarkers_SOURCES = printmarkers.c
29 printmarkers_LDADD = $(LIBAUDIOFILE) -lm
31 sixteen_to_eight_SOURCES = sixteen-to-eight.c TestUtilities.cpp TestUtilities.h
32 +sixteen_stereo_to_eight_mono_SOURCES = sixteen-stereo-to-eight-mono.c TestUtilities.cpp TestUtilities.h
34 testchannelmatrix_SOURCES = testchannelmatrix.c TestUtilities.cpp TestUtilities.h
36 --- /dev/null
37 +++ b/test/sixteen-stereo-to-eight-mono.c
38 @@ -0,0 +1,118 @@
39 +/*
40 + Audio File Library
42 + Copyright 2000, Silicon Graphics, Inc.
44 + This program is free software; you can redistribute it and/or modify
45 + it under the terms of the GNU General Public License as published by
46 + the Free Software Foundation; either version 2 of the License, or
47 + (at your option) any later version.
49 + This program is distributed in the hope that it will be useful,
50 + but WITHOUT ANY WARRANTY; without even the implied warranty of
51 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
52 + GNU General Public License for more details.
54 + You should have received a copy of the GNU General Public License along
55 + with this program; if not, write to the Free Software Foundation, Inc.,
56 + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
57 +*/
59 +/*
60 + sixteen-stereo-to-eight-mono.c
62 + This program tests the conversion from 2-channel 16-bit integers to
63 + 1-channel 8-bit integers.
64 +*/
66 +#ifdef HAVE_CONFIG_H
67 +#include <config.h>
68 +#endif
70 +#include <stdint.h>
71 +#include <stdio.h>
72 +#include <stdlib.h>
73 +#include <string.h>
74 +#include <unistd.h>
75 +#include <limits.h>
77 +#include <audiofile.h>
79 +#include "TestUtilities.h"
81 +int main (int argc, char **argv)
83 + AFfilehandle file;
84 + AFfilesetup setup;
85 + int16_t frames16[] = {14298, 392, 3923, -683, 958, -1921};
86 + int8_t frames8[] = {28, 6, -2};
87 + int i, frameCount = 3;
88 + int8_t byte;
89 + AFframecount result;
91 + setup = afNewFileSetup();
93 + afInitFileFormat(setup, AF_FILE_WAVE);
95 + afInitSampleFormat(setup, AF_DEFAULT_TRACK, AF_SAMPFMT_TWOSCOMP, 16);
96 + afInitChannels(setup, AF_DEFAULT_TRACK, 2);
98 + char *testFileName;
99 + if (!createTemporaryFile("sixteen-to-eight", &testFileName))
101 + fprintf(stderr, "Could not create temporary file.\n");
102 + exit(EXIT_FAILURE);
105 + file = afOpenFile(testFileName, "w", setup);
106 + if (file == AF_NULL_FILEHANDLE)
108 + fprintf(stderr, "could not open file for writing\n");
109 + exit(EXIT_FAILURE);
112 + afFreeFileSetup(setup);
114 + afWriteFrames(file, AF_DEFAULT_TRACK, frames16, frameCount);
116 + afCloseFile(file);
118 + file = afOpenFile(testFileName, "r", AF_NULL_FILESETUP);
119 + if (file == AF_NULL_FILEHANDLE)
121 + fprintf(stderr, "could not open file for reading\n");
122 + exit(EXIT_FAILURE);
125 + afSetVirtualSampleFormat(file, AF_DEFAULT_TRACK, AF_SAMPFMT_TWOSCOMP, 8);
126 + afSetVirtualChannels(file, AF_DEFAULT_TRACK, 1);
128 + for (i=0; i<frameCount; i++)
130 + /* Read one frame. */
131 + result = afReadFrames(file, AF_DEFAULT_TRACK, &byte, 1);
133 + if (result != 1)
134 + break;
136 + /* Compare the byte read with its precalculated value. */
137 + if (memcmp(&byte, &frames8[i], 1) != 0)
139 + printf("error\n");
140 + printf("expected %d, got %d\n", frames8[i], byte);
141 + exit(EXIT_FAILURE);
143 + else
145 +#ifdef DEBUG
146 + printf("got what was expected: %d\n", byte);
147 +#endif
151 + afCloseFile(file);
152 + unlink(testFileName);
153 + free(testFileName);
155 + exit(EXIT_SUCCESS);