0015-oggenc-Fix-large-alloca-on-bad-AIFF-input-CVE-2015-6.patch 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. From: Petter Reinholdtsen <pere@debian.org>
  2. Date: Tue, 22 Sep 2015 14:56:58 +0200
  3. Subject: oggenc: Fix large alloca on bad AIFF input (CVE-2015-6749).
  4. Author: Mark Harris <mark.hsj@gmail.com>
  5. Origin: https://trac.xiph.org/attachment/ticket/2212/0001-oggenc-Fix-large-alloca-on-bad-AIFF-input.patch
  6. Bug-Debian: https://bugs.debian.org/797461
  7. Forwarded: https://trac.xiph.org/ticket/2212
  8. Reviewed-By: Petter Reinholdtsen <pere@hungry.com>
  9. Last-Update: 2015-09-22
  10. ---
  11. oggenc/audio.c | 10 +++++-----
  12. 1 file changed, 5 insertions(+), 5 deletions(-)
  13. diff --git a/oggenc/audio.c b/oggenc/audio.c
  14. index 22bbed4..05e42b3 100644
  15. --- a/oggenc/audio.c
  16. +++ b/oggenc/audio.c
  17. @@ -245,8 +245,8 @@ static int aiff_permute_matrix[6][6] =
  18. int aiff_open(FILE *in, oe_enc_opt *opt, unsigned char *buf, int buflen)
  19. {
  20. int aifc; /* AIFC or AIFF? */
  21. - unsigned int len;
  22. - unsigned char *buffer;
  23. + unsigned int len, readlen;
  24. + unsigned char buffer[22];
  25. unsigned char buf2[8];
  26. aiff_fmt format;
  27. aifffile *aiff = malloc(sizeof(aifffile));
  28. @@ -269,9 +269,9 @@ int aiff_open(FILE *in, oe_enc_opt *opt, unsigned char *buf, int buflen)
  29. return 0; /* Weird common chunk */
  30. }
  31. - buffer = alloca(len);
  32. -
  33. - if(fread(buffer,1,len,in) < len)
  34. + readlen = len < sizeof(buffer) ? len : sizeof(buffer);
  35. + if(fread(buffer,1,readlen,in) < readlen ||
  36. + (len > readlen && !seek_forward(in, len-readlen)))
  37. {
  38. fprintf(stderr, _("Warning: Unexpected EOF in reading AIFF header\n"));
  39. return 0;