Blame SOURCES/vorbis-tools-1.4.0-CVE-2014-9638-CVE-2014-9639.patch

e2271c
From 32c4958c4d113562f879ce76664fe785f93bba7c Mon Sep 17 00:00:00 2001
e2271c
From: Kamil Dudka <kdudka@redhat.com>
e2271c
Date: Thu, 19 Feb 2015 15:32:24 +0100
e2271c
Subject: [PATCH] oggenc: validate count of channels in the header
e2271c
e2271c
... in order to prevent a division by zero (CVE-2014-9638) and integer
e2271c
overflow (CVE-2014-9639).
e2271c
e2271c
Bug: https://trac.xiph.org/ticket/2136
e2271c
Bug: https://trac.xiph.org/ticket/2137
e2271c
---
e2271c
 oggenc/audio.c | 19 +++++++++++++++++--
e2271c
 1 file changed, 17 insertions(+), 2 deletions(-)
e2271c
e2271c
diff --git a/oggenc/audio.c b/oggenc/audio.c
e2271c
index 22bbed4..1cbb214 100644
e2271c
--- a/oggenc/audio.c
e2271c
+++ b/oggenc/audio.c
e2271c
@@ -13,6 +13,7 @@
e2271c
 #include <config.h>
e2271c
 #endif
e2271c
 
e2271c
+#include <limits.h>
e2271c
 #include <stdlib.h>
e2271c
 #include <stdio.h>
e2271c
 #include <string.h>
e2271c
@@ -251,6 +252,7 @@ int aiff_open(FILE *in, oe_enc_opt *opt, unsigned char *buf, int buflen)
e2271c
     aiff_fmt format;
e2271c
     aifffile *aiff = malloc(sizeof(aifffile));
e2271c
     int i;
e2271c
+    long channels;
e2271c
 
e2271c
     if(buf[11]=='C')
e2271c
         aifc=1;
e2271c
@@ -277,11 +279,17 @@ int aiff_open(FILE *in, oe_enc_opt *opt, unsigned char *buf, int buflen)
e2271c
         return 0;
e2271c
     }
e2271c
 
e2271c
-    format.channels = READ_U16_BE(buffer);
e2271c
+    format.channels = channels = READ_U16_BE(buffer);
e2271c
     format.totalframes = READ_U32_BE(buffer+2);
e2271c
     format.samplesize = READ_U16_BE(buffer+6);
e2271c
     format.rate = (int)read_IEEE80(buffer+8);
e2271c
 
e2271c
+    if(channels <= 0L || SHRT_MAX < channels)
e2271c
+    {
e2271c
+        fprintf(stderr, _("Warning: Unsupported count of channels in AIFF header\n"));
e2271c
+        return 0;
e2271c
+    }
e2271c
+
e2271c
     aiff->bigendian = 1;
e2271c
 
e2271c
     if(aifc)
e2271c
@@ -412,6 +420,7 @@ int wav_open(FILE *in, oe_enc_opt *opt, unsigned char *oldbuf, int buflen)
e2271c
     wav_fmt format;
e2271c
     wavfile *wav = malloc(sizeof(wavfile));
e2271c
     int i;
e2271c
+    long channels;
e2271c
 
e2271c
     /* Ok. At this point, we know we have a WAV file. Now we have to detect
e2271c
      * whether we support the subtype, and we have to find the actual data
e2271c
@@ -449,12 +458,18 @@ int wav_open(FILE *in, oe_enc_opt *opt, unsigned char *oldbuf, int buflen)
e2271c
     }
e2271c
 
e2271c
     format.format =      READ_U16_LE(buf);
e2271c
-    format.channels =    READ_U16_LE(buf+2);
e2271c
+    format.channels = channels = READ_U16_LE(buf+2);
e2271c
     format.samplerate =  READ_U32_LE(buf+4);
e2271c
     format.bytespersec = READ_U32_LE(buf+8);
e2271c
     format.align =       READ_U16_LE(buf+12);
e2271c
     format.samplesize =  READ_U16_LE(buf+14);
e2271c
 
e2271c
+    if(channels <= 0L || SHRT_MAX < channels)
e2271c
+    {
e2271c
+        fprintf(stderr, _("Warning: Unsupported count of channels in WAV header\n"));
e2271c
+        return 0;
e2271c
+    }
e2271c
+
e2271c
     if(format.format == -2) /* WAVE_FORMAT_EXTENSIBLE */
e2271c
     {
e2271c
       if(len<40)
e2271c
-- 
e2271c
2.1.0
e2271c