aboutsummaryrefslogtreecommitdiffstats
path: root/main/libsndfile/CVE-2018-19758-and-CVE-2019-3832.patch
blob: 3b08a642129ddb49b61ccc0666ae6ad181a5afa1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
diff --git a/src/wav.c b/src/wav.c
index 4b943dc..6020f20 100644
--- a/src/wav.c
+++ b/src/wav.c
@@ -1094,6 +1094,10 @@ wav_write_header (SF_PRIVATE *psf, int calc_length)
 		psf_binheader_writef (psf, "44", 0, 0) ; /* SMTPE format */
 		psf_binheader_writef (psf, "44", psf->instrument->loop_count, 0) ;
 
+		/* Make sure we don't read past the loops array end. */
+		if (psf->instrument->loop_count > ARRAY_LEN (psf->instrument->loops))
+			psf->instrument->loop_count = ARRAY_LEN (psf->instrument->loops) ;
+
 		for (tmp = 0 ; tmp < psf->instrument->loop_count ; tmp++)
 		{	int type ;