gnu: libsndfile: Fix CVE-2017-{8361,8362,8363,8365}.
[jackhill/guix/guix.git] / gnu / packages / patches / libsndfile-CVE-2017-8362.patch
1 Fix CVE-2017-8362:
2
3 https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2017-8362
4
5 Patch copied from upstream source repository:
6
7 https://github.com/erikd/libsndfile/commit/ef1dbb2df1c0e741486646de40bd638a9c4cd808
8
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
13
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.
17
18 Closes: https://github.com/erikd/libsndfile/issues/231
19 ---
20 src/flac.c | 11 +++++++++--
21 1 file changed, 9 insertions(+), 2 deletions(-)
22
23 diff --git a/src/flac.c b/src/flac.c
24 index 5a4f8c21..e4f9aaa0 100644
25 --- a/src/flac.c
26 +++ b/src/flac.c
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 ;
30
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 ;
36 + return 0 ;
37 + } ;
38 +
39 /*
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)
43 return 0 ;
44 } ;
45
46 -
47 len = SF_MIN (pflac->len, frame->header.blocksize) ;
48
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 ;
58 return ;
59 --
60 2.12.2
61