0016-oggenc-validate-count-of-channels-in-the-header-CVE-.patch 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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 &
  4. CVE-2014-9639)
  5. Author: Kamil Dudka <kdudka@redhat.com>
  6. Origin: http://lists.xiph.org/pipermail/vorbis-dev/2015-February/020423.html
  7. Bug: https://trac.xiph.org/ticket/2136
  8. Bug: https://trac.xiph.org/ticket/2137
  9. Bug-Debian: https://bugs.debian.org/776086
  10. Forwarded: not-needed
  11. Reviewed-By: Petter Reinholdtsen <pere@hungry.com>
  12. Last-Update: 2015-09-22
  13. ---
  14. oggenc/audio.c | 18 ++++++++++++++++--
  15. 1 file changed, 16 insertions(+), 2 deletions(-)
  16. diff --git a/oggenc/audio.c b/oggenc/audio.c
  17. index 05e42b3..1b3f179 100644
  18. --- a/oggenc/audio.c
  19. +++ b/oggenc/audio.c
  20. @@ -13,6 +13,7 @@
  21. #include <config.h>
  22. #endif
  23. +#include <limits.h>
  24. #include <stdlib.h>
  25. #include <stdio.h>
  26. #include <string.h>
  27. @@ -251,6 +252,7 @@ int aiff_open(FILE *in, oe_enc_opt *opt, unsigned char *buf, int buflen)
  28. aiff_fmt format;
  29. aifffile *aiff = malloc(sizeof(aifffile));
  30. int i;
  31. + long channels;
  32. if(buf[11]=='C')
  33. aifc=1;
  34. @@ -277,11 +279,16 @@ int aiff_open(FILE *in, oe_enc_opt *opt, unsigned char *buf, int buflen)
  35. return 0;
  36. }
  37. - format.channels = READ_U16_BE(buffer);
  38. + format.channels = channels = READ_U16_BE(buffer);
  39. format.totalframes = READ_U32_BE(buffer+2);
  40. format.samplesize = READ_U16_BE(buffer+6);
  41. format.rate = (int)read_IEEE80(buffer+8);
  42. + if(channels <= 0L || SHRT_MAX < channels)
  43. + {
  44. + fprintf(stderr, _("Warning: Unsupported count of channels in AIFF header\n"));
  45. + return 0;
  46. + }
  47. aiff->bigendian = 1;
  48. if(aifc)
  49. @@ -412,6 +419,7 @@ int wav_open(FILE *in, oe_enc_opt *opt, unsigned char *oldbuf, int buflen)
  50. wav_fmt format;
  51. wavfile *wav = malloc(sizeof(wavfile));
  52. int i;
  53. + long channels;
  54. /* Ok. At this point, we know we have a WAV file. Now we have to detect
  55. * whether we support the subtype, and we have to find the actual data
  56. @@ -449,12 +457,18 @@ int wav_open(FILE *in, oe_enc_opt *opt, unsigned char *oldbuf, int buflen)
  57. }
  58. format.format = READ_U16_LE(buf);
  59. - format.channels = READ_U16_LE(buf+2);
  60. + format.channels = channels = READ_U16_LE(buf+2);
  61. format.samplerate = READ_U32_LE(buf+4);
  62. format.bytespersec = READ_U32_LE(buf+8);
  63. format.align = READ_U16_LE(buf+12);
  64. format.samplesize = READ_U16_LE(buf+14);
  65. + if(channels <= 0L || SHRT_MAX < channels)
  66. + {
  67. + fprintf(stderr, _("Warning: Unsupported count of channels in WAV header\n"));
  68. + return 0;
  69. + }
  70. +
  71. if(format.format == -2) /* WAVE_FORMAT_EXTENSIBLE */
  72. {
  73. if(len<40)