0002-oggenc-validate-count-of-channels-in-the-header-CVE-.patch 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. From 3bbabc06c4b35c84f6747ed850213161aca568c7 Mon Sep 17 00:00:00 2001
  2. From: Petter Reinholdtsen <pere@debian.org>
  3. Date: Tue, 22 Sep 2015 15:14:06 +0200
  4. Subject: [PATCH] oggenc: validate count of channels in the header
  5. (CVE-2014-9638 & CVE-2014-9639)
  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
  11. Forwarded: not-needed
  12. Reviewed-By: Petter Reinholdtsen <pere@hungry.com>
  13. Last-Update: 2015-09-22
  14. Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
  15. ---
  16. oggenc/audio.c | 18 ++++++++++++++++--
  17. 1 file changed, 16 insertions(+), 2 deletions(-)
  18. diff --git a/oggenc/audio.c b/oggenc/audio.c
  19. index 4921fb9..535a704 100644
  20. --- a/oggenc/audio.c
  21. +++ b/oggenc/audio.c
  22. @@ -13,6 +13,7 @@
  23. #include <config.h>
  24. #endif
  25. +#include <limits.h>
  26. #include <stdlib.h>
  27. #include <stdio.h>
  28. #include <string.h>
  29. @@ -251,6 +252,7 @@ int aiff_open(FILE *in, oe_enc_opt *opt, unsigned char *buf, int buflen)
  30. aiff_fmt format;
  31. aifffile *aiff = malloc(sizeof(aifffile));
  32. int i;
  33. + long channels;
  34. if(buf[11]=='C')
  35. aifc=1;
  36. @@ -277,11 +279,16 @@ int aiff_open(FILE *in, oe_enc_opt *opt, unsigned char *buf, int buflen)
  37. return 0;
  38. }
  39. - format.channels = READ_U16_BE(buffer);
  40. + format.channels = channels = READ_U16_BE(buffer);
  41. format.totalframes = READ_U32_BE(buffer+2);
  42. format.samplesize = READ_U16_BE(buffer+6);
  43. format.rate = (int)read_IEEE80(buffer+8);
  44. + if(channels <= 0L || SHRT_MAX < channels)
  45. + {
  46. + fprintf(stderr, _("Warning: Unsupported count of channels in AIFF header\n"));
  47. + return 0;
  48. + }
  49. aiff->bigendian = 1;
  50. if(aifc)
  51. @@ -416,6 +423,7 @@ int wav_open(FILE *in, oe_enc_opt *opt, unsigned char *oldbuf, int buflen)
  52. wav_fmt format;
  53. wavfile *wav = malloc(sizeof(wavfile));
  54. int i;
  55. + long channels;
  56. /* Ok. At this point, we know we have a WAV file. Now we have to detect
  57. * whether we support the subtype, and we have to find the actual data
  58. @@ -453,12 +461,18 @@ int wav_open(FILE *in, oe_enc_opt *opt, unsigned char *oldbuf, int buflen)
  59. }
  60. format.format = READ_U16_LE(buf);
  61. - format.channels = READ_U16_LE(buf+2);
  62. + format.channels = channels = READ_U16_LE(buf+2);
  63. format.samplerate = READ_U32_LE(buf+4);
  64. format.bytespersec = READ_U32_LE(buf+8);
  65. format.align = READ_U16_LE(buf+12);
  66. format.samplesize = READ_U16_LE(buf+14);
  67. + if(channels <= 0L || SHRT_MAX < channels)
  68. + {
  69. + fprintf(stderr, _("Warning: Unsupported count of channels in WAV header\n"));
  70. + return 0;
  71. + }
  72. +
  73. if(format.format == -2) /* WAVE_FORMAT_EXTENSIBLE */
  74. {
  75. if(len<40)
  76. --
  77. 2.20.1