Brad Bishop | 220d553 | 2018-08-14 00:59:39 +0100 | [diff] [blame] | 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 | |
| 6 | This prevents division by zero later in the code. |
| 7 | |
| 8 | While the trivial case to catch this (i.e. sf.channels < 1) has already |
| 9 | been covered, a crafted file may report a number of channels that is |
| 10 | so high (i.e. > INT_MAX/sizeof(double)) that it "somehow" gets |
| 11 | miscalculated to zero (if this makes sense) in the determination of the |
| 12 | blockwidth. Since we only support a limited number of channels anyway, |
| 13 | make sure to check here as well. |
| 14 | |
| 15 | CVE: CVE-2017-14634 |
| 16 | |
| 17 | Closes: https://github.com/erikd/libsndfile/issues/318 |
| 18 | |
| 19 | Upstream-Status: Backport [https://github.com/erikd/libsndfile/commit/85c877d5072866aadbe8ed0c3e0590fbb5e16788] |
| 20 | |
| 21 | Signed-off-by: Erik de Castro Lopo <erikd@mega-nerd.com> |
| 22 | Signed-off-by: Jagadeesh Krishnanjanappa <jkrishnanjanappa@mvista.com> |
| 23 | --- |
| 24 | src/double64.c | 2 +- |
| 25 | 1 file changed, 1 insertion(+), 1 deletion(-) |
| 26 | |
| 27 | diff --git a/src/double64.c b/src/double64.c |
| 28 | index b318ea8..78dfef7 100644 |
| 29 | --- a/src/double64.c |
| 30 | +++ b/src/double64.c |
| 31 | @@ -91,7 +91,7 @@ int |
| 32 | double64_init (SF_PRIVATE *psf) |
| 33 | { static int double64_caps ; |
| 34 | |
| 35 | - if (psf->sf.channels < 1) |
| 36 | + if (psf->sf.channels < 1 || psf->sf.channels > SF_MAX_CHANNELS) |
| 37 | { psf_log_printf (psf, "double64_init : internal error : channels = %d\n", psf->sf.channels) ; |
| 38 | return SFE_INTERNAL ; |
| 39 | } ; |
| 40 | -- |
| 41 | 2.13.3 |
| 42 | |