Merge pull request #268619 from tweag/lib-descriptions
[NixPkgs.git] / pkgs / development / libraries / audiofile / CVE-2015-7747.patch
bloba01aaa14dcee4f1e60099e3a33a8a253429c9f12
1 Description: fix buffer overflow when changing both sample format and
2 number of channels
3 Origin: backport, https://github.com/mpruett/audiofile/pull/25
4 Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/audiofile/+bug/1502721
5 Bug-Debian: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=801102
7 Index: audiofile-0.3.6/libaudiofile/modules/ModuleState.cpp
8 ===================================================================
9 --- audiofile-0.3.6.orig/libaudiofile/modules/ModuleState.cpp 2015-10-20 08:00:58.036128202 -0400
10 +++ audiofile-0.3.6/libaudiofile/modules/ModuleState.cpp 2015-10-20 08:00:58.036128202 -0400
11 @@ -402,7 +402,7 @@
12 addModule(new Transform(outfc, in.pcm, out.pcm));
14 if (in.channelCount != out.channelCount)
15 - addModule(new ApplyChannelMatrix(infc, isReading,
16 + addModule(new ApplyChannelMatrix(outfc, isReading,
17 in.channelCount, out.channelCount,
18 in.pcm.minClip, in.pcm.maxClip,
19 track->channelMatrix));
20 Index: audiofile-0.3.6/test/Makefile.am
21 ===================================================================
22 --- audiofile-0.3.6.orig/test/Makefile.am 2015-10-20 08:00:58.036128202 -0400
23 +++ audiofile-0.3.6/test/Makefile.am 2015-10-20 08:00:58.036128202 -0400
24 @@ -26,6 +26,7 @@
25 VirtualFile \
26 floatto24 \
27 query2 \
28 + sixteen-stereo-to-eight-mono \
29 sixteen-to-eight \
30 testchannelmatrix \
31 testdouble \
32 @@ -139,6 +140,7 @@
33 printmarkers_LDADD = $(LIBAUDIOFILE) -lm
35 sixteen_to_eight_SOURCES = sixteen-to-eight.c TestUtilities.cpp TestUtilities.h
36 +sixteen_stereo_to_eight_mono_SOURCES = sixteen-stereo-to-eight-mono.c TestUtilities.cpp TestUtilities.h
38 testchannelmatrix_SOURCES = testchannelmatrix.c TestUtilities.cpp TestUtilities.h
40 Index: audiofile-0.3.6/test/sixteen-stereo-to-eight-mono.c
41 ===================================================================
42 --- /dev/null 1970-01-01 00:00:00.000000000 +0000
43 +++ audiofile-0.3.6/test/sixteen-stereo-to-eight-mono.c 2015-10-20 08:33:57.512286416 -0400
44 @@ -0,0 +1,117 @@
45 +/*
46 + Audio File Library
48 + Copyright 2000, Silicon Graphics, Inc.
50 + This program is free software; you can redistribute it and/or modify
51 + it under the terms of the GNU General Public License as published by
52 + the Free Software Foundation; either version 2 of the License, or
53 + (at your option) any later version.
55 + This program is distributed in the hope that it will be useful,
56 + but WITHOUT ANY WARRANTY; without even the implied warranty of
57 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
58 + GNU General Public License for more details.
60 + You should have received a copy of the GNU General Public License along
61 + with this program; if not, write to the Free Software Foundation, Inc.,
62 + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
63 +*/
65 +/*
66 + sixteen-stereo-to-eight-mono.c
68 + This program tests the conversion from 2-channel 16-bit integers to
69 + 1-channel 8-bit integers.
70 +*/
72 +#ifdef HAVE_CONFIG_H
73 +#include <config.h>
74 +#endif
76 +#include <stdint.h>
77 +#include <stdio.h>
78 +#include <stdlib.h>
79 +#include <string.h>
80 +#include <unistd.h>
81 +#include <limits.h>
83 +#include <audiofile.h>
85 +#include "TestUtilities.h"
87 +int main (int argc, char **argv)
89 + AFfilehandle file;
90 + AFfilesetup setup;
91 + int16_t frames16[] = {14298, 392, 3923, -683, 958, -1921};
92 + int8_t frames8[] = {28, 6, -2};
93 + int i, frameCount = 3;
94 + int8_t byte;
95 + AFframecount result;
97 + setup = afNewFileSetup();
99 + afInitFileFormat(setup, AF_FILE_WAVE);
101 + afInitSampleFormat(setup, AF_DEFAULT_TRACK, AF_SAMPFMT_TWOSCOMP, 16);
102 + afInitChannels(setup, AF_DEFAULT_TRACK, 2);
104 + char testFileName[PATH_MAX];
105 + if (!createTemporaryFile("sixteen-to-eight", testFileName))
107 + fprintf(stderr, "Could not create temporary file.\n");
108 + exit(EXIT_FAILURE);
111 + file = afOpenFile(testFileName, "w", setup);
112 + if (file == AF_NULL_FILEHANDLE)
114 + fprintf(stderr, "could not open file for writing\n");
115 + exit(EXIT_FAILURE);
118 + afFreeFileSetup(setup);
120 + afWriteFrames(file, AF_DEFAULT_TRACK, frames16, frameCount);
122 + afCloseFile(file);
124 + file = afOpenFile(testFileName, "r", AF_NULL_FILESETUP);
125 + if (file == AF_NULL_FILEHANDLE)
127 + fprintf(stderr, "could not open file for reading\n");
128 + exit(EXIT_FAILURE);
131 + afSetVirtualSampleFormat(file, AF_DEFAULT_TRACK, AF_SAMPFMT_TWOSCOMP, 8);
132 + afSetVirtualChannels(file, AF_DEFAULT_TRACK, 1);
134 + for (i=0; i<frameCount; i++)
136 + /* Read one frame. */
137 + result = afReadFrames(file, AF_DEFAULT_TRACK, &byte, 1);
139 + if (result != 1)
140 + break;
142 + /* Compare the byte read with its precalculated value. */
143 + if (memcmp(&byte, &frames8[i], 1) != 0)
145 + printf("error\n");
146 + printf("expected %d, got %d\n", frames8[i], byte);
147 + exit(EXIT_FAILURE);
149 + else
151 +#ifdef DEBUG
152 + printf("got what was expected: %d\n", byte);
153 +#endif
157 + afCloseFile(file);
158 + unlink(testFileName);
160 + exit(EXIT_SUCCESS);