0001-double64_init-Check-psf-sf.channels-against-upper-bo.patch 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. From 85c877d5072866aadbe8ed0c3e0590fbb5e16788 Mon Sep 17 00:00:00 2001
  2. From: Fabian Greffrath <fabian@greffrath.com>
  3. Date: Thu, 28 Sep 2017 12:15:04 +0200
  4. Subject: [PATCH] double64_init: Check psf->sf.channels against upper bound
  5. This prevents division by zero later in the code.
  6. While the trivial case to catch this (i.e. sf.channels < 1) has already
  7. been covered, a crafted file may report a number of channels that is
  8. so high (i.e. > INT_MAX/sizeof(double)) that it "somehow" gets
  9. miscalculated to zero (if this makes sense) in the determination of the
  10. blockwidth. Since we only support a limited number of channels anyway,
  11. make sure to check here as well.
  12. CVE-2017-14634
  13. Closes: https://github.com/erikd/libsndfile/issues/318
  14. Signed-off-by: Erik de Castro Lopo <erikd@mega-nerd.com>
  15. Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
  16. ---
  17. src/double64.c | 2 +-
  18. 1 file changed, 1 insertion(+), 1 deletion(-)
  19. diff --git a/src/double64.c b/src/double64.c
  20. index b318ea86..78dfef7f 100644
  21. --- a/src/double64.c
  22. +++ b/src/double64.c
  23. @@ -91,7 +91,7 @@ int
  24. double64_init (SF_PRIVATE *psf)
  25. { static int double64_caps ;
  26. - if (psf->sf.channels < 1)
  27. + if (psf->sf.channels < 1 || psf->sf.channels > SF_MAX_CHANNELS)
  28. { psf_log_printf (psf, "double64_init : internal error : channels = %d\n", psf->sf.channels) ;
  29. return SFE_INTERNAL ;
  30. } ;
  31. --
  32. 2.11.0