From 3a7884bf532b134804a83632527d2de9a6b25a30 Mon Sep 17 00:00:00 2001 From: Erik de Castro Lopo Date: Tue, 14 Feb 2017 21:21:54 +1100 Subject: flac/encode.c: Fix an integer overflow MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When encoding a 24 bit multichannel W64 file on a 32 bit system, a calculation could overflow resulting in a "got partial sample" error and early termination of the encoding process. The fix was to replace the cast to `size_t` (which is only 32 bits on a 32 bit system) with a cast to `uin64_t`. Thanks to Janne Hyvärinen for helping to track down the problem. Closes: https://sourceforge.net/p/flac/bugs/453 --- src/flac/encode.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/flac/encode.c b/src/flac/encode.c index 73c15765..be3869f0 100644 --- a/src/flac/encode.c +++ b/src/flac/encode.c @@ -1387,9 +1387,9 @@ int flac__encode_file(FILE *infile, FLAC__off_t infilesize, const char *infilena case FORMAT_AIFF_C: while(encoder_session.fmt.iff.data_bytes > 0) { const size_t bytes_to_read = - min (sizeof (ubuffer.u8), - min ((size_t)encoder_session.fmt.iff.data_bytes, - CHUNK_OF_SAMPLES * (size_t)encoder_session.info.bytes_per_wide_sample)); + (size_t) min (sizeof (ubuffer.u8), + min (encoder_session.fmt.iff.data_bytes, + CHUNK_OF_SAMPLES * (uint64_t) encoder_session.info.bytes_per_wide_sample)); size_t bytes_read = fread(ubuffer.u8, sizeof(uint8_t), bytes_to_read, infile); if(bytes_read == 0) { if(ferror(infile)) { -- cgit v1.2.1