1 From: Petter Reinholdtsen <pere@debian.org>
2 Date: Tue, 22 Sep 2015 15:14:06 +0200
3 Subject: oggenc: validate count of channels in the header (CVE-2014-9638 &
6 Author: Kamil Dudka <kdudka@redhat.com>
7 Origin: http://lists.xiph.org/pipermail/vorbis-dev/2015-February/020423.html
8 Bug: https://trac.xiph.org/ticket/2136
9 Bug: https://trac.xiph.org/ticket/2137
10 Bug-Debian: https://bugs.debian.org/776086
12 Reviewed-By: Petter Reinholdtsen <pere@hungry.com>
13 Last-Update: 2015-09-22
15 oggenc/audio.c | 18 ++++++++++++++++--
16 1 file changed, 16 insertions(+), 2 deletions(-)
18 diff --git a/oggenc/audio.c b/oggenc/audio.c
19 index 05e42b3..1b3f179 100644
30 @@ -251,6 +252,7 @@ int aiff_open(FILE *in, oe_enc_opt *opt, unsigned char *buf, int buflen)
32 aifffile *aiff = malloc(sizeof(aifffile));
38 @@ -277,11 +279,16 @@ int aiff_open(FILE *in, oe_enc_opt *opt, unsigned char *buf, int buflen)
42 - format.channels = READ_U16_BE(buffer);
43 + format.channels = channels = READ_U16_BE(buffer);
44 format.totalframes = READ_U32_BE(buffer+2);
45 format.samplesize = READ_U16_BE(buffer+6);
46 format.rate = (int)read_IEEE80(buffer+8);
48 + if(channels <= 0L || SHRT_MAX < channels)
50 + fprintf(stderr, _("Warning: Unsupported count of channels in AIFF header\n"));
56 @@ -412,6 +419,7 @@ int wav_open(FILE *in, oe_enc_opt *opt, unsigned char *oldbuf, int buflen)
58 wavfile *wav = malloc(sizeof(wavfile));
62 /* Ok. At this point, we know we have a WAV file. Now we have to detect
63 * whether we support the subtype, and we have to find the actual data
64 @@ -449,12 +457,18 @@ int wav_open(FILE *in, oe_enc_opt *opt, unsigned char *oldbuf, int buflen)
67 format.format = READ_U16_LE(buf);
68 - format.channels = READ_U16_LE(buf+2);
69 + format.channels = channels = READ_U16_LE(buf+2);
70 format.samplerate = READ_U32_LE(buf+4);
71 format.bytespersec = READ_U32_LE(buf+8);
72 format.align = READ_U16_LE(buf+12);
73 format.samplesize = READ_U16_LE(buf+14);
75 + if(channels <= 0L || SHRT_MAX < channels)
77 + fprintf(stderr, _("Warning: Unsupported count of channels in WAV header\n"));
81 if(format.format == -2) /* WAVE_FORMAT_EXTENSIBLE */