3 https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2017-8362
5 Patch copied from upstream source repository:
7 https://github.com/erikd/libsndfile/commit/ef1dbb2df1c0e741486646de40bd638a9c4cd808
9 From ef1dbb2df1c0e741486646de40bd638a9c4cd808 Mon Sep 17 00:00:00 2001
10 From: Erik de Castro Lopo <erikd@mega-nerd.com>
11 Date: Fri, 14 Apr 2017 15:19:16 +1000
12 Subject: [PATCH] src/flac.c: Fix a buffer read overflow
14 A file (generated by a fuzzer) which increased the number of channels
15 from one frame to the next could cause a read beyond the end of the
16 buffer provided by libFLAC. Only option is to abort the read.
18 Closes: https://github.com/erikd/libsndfile/issues/231
20 src/flac.c | 11 +++++++++--
21 1 file changed, 9 insertions(+), 2 deletions(-)
23 diff --git a/src/flac.c b/src/flac.c
24 index 5a4f8c21..e4f9aaa0 100644
27 @@ -169,6 +169,14 @@ flac_buffer_copy (SF_PRIVATE *psf)
28 const int32_t* const *buffer = pflac->wbuffer ;
29 unsigned i = 0, j, offset, channels, len ;
31 + if (psf->sf.channels != (int) frame->header.channels)
32 + { psf_log_printf (psf, "Error: FLAC frame changed from %d to %d channels\n"
33 + "Nothing to do but to error out.\n" ,
34 + psf->sf.channels, frame->header.channels) ;
35 + psf->error = SFE_FLAC_CHANNEL_COUNT_CHANGED ;
40 ** frame->header.blocksize is variable and we're using a constant blocksize
41 ** of FLAC__MAX_BLOCK_SIZE.
42 @@ -202,7 +210,6 @@ flac_buffer_copy (SF_PRIVATE *psf)
47 len = SF_MIN (pflac->len, frame->header.blocksize) ;
49 if (pflac->remain % channels != 0)
50 @@ -436,7 +443,7 @@ sf_flac_meta_callback (const FLAC__StreamDecoder * UNUSED (decoder), const FLAC_
51 { case FLAC__METADATA_TYPE_STREAMINFO :
52 if (psf->sf.channels > 0 && psf->sf.channels != (int) metadata->data.stream_info.channels)
53 { psf_log_printf (psf, "Error: FLAC stream changed from %d to %d channels\n"
54 - "Nothing to be but to error out.\n" ,
55 + "Nothing to do but to error out.\n" ,
56 psf->sf.channels, metadata->data.stream_info.channels) ;
57 psf->error = SFE_FLAC_CHANNEL_COUNT_CHANGED ;