1 Fix CVE-2015-6749 - invalid AIFF file causes alloca() buffer overflow.
2 See https://trac.xiph.org/ticket/2212
5 Signed-off-by: Gustavo Zacarias <gustavo@zacarias.com.ar>
7 diff --git a/oggenc/audio.c b/oggenc/audio.c
8 index 477da8c..4921fb9 100644
11 @@ -245,8 +245,8 @@ static int aiff_permute_matrix[6][6] =
12 int aiff_open(FILE *in, oe_enc_opt *opt, unsigned char *buf, int buflen)
14 int aifc; /* AIFC or AIFF? */
16 - unsigned char *buffer;
17 + unsigned int len, readlen;
18 + unsigned char buffer[22];
19 unsigned char buf2[8];
21 aifffile *aiff = malloc(sizeof(aifffile));
22 @@ -269,9 +269,9 @@ int aiff_open(FILE *in, oe_enc_opt *opt, unsigned char *buf, int buflen)
23 return 0; /* Weird common chunk */
26 - buffer = alloca(len);
28 - if(fread(buffer,1,len,in) < len)
29 + readlen = len < sizeof(buffer) ? len : sizeof(buffer);
30 + if(fread(buffer,1,readlen,in) < readlen ||
31 + (len > readlen && !seek_forward(in, len-readlen)))
33 fprintf(stderr, _("Warning: Unexpected EOF in reading AIFF header\n"));