Fix max channel count bug 01/211501/1 accepted/tizen_5.5_unified accepted/tizen_5.5_unified_mobile_hotfix accepted/tizen_5.5_unified_wearable_hotfix accepted/tizen_6.0_unified_hotfix accepted/tizen_unified tizen_5.5 tizen_5.5_mobile_hotfix tizen_5.5_tv tizen_5.5_wearable_hotfix tizen_6.0_hotfix accepted/tizen/5.5/unified/20191031.012002 accepted/tizen/5.5/unified/mobile/hotfix/20201027.074340 accepted/tizen/5.5/unified/wearable/hotfix/20201027.100651 accepted/tizen/6.0/unified/20201030.110532 accepted/tizen/6.0/unified/hotfix/20201102.234021 accepted/tizen/6.0/unified/hotfix/20201103.051225 accepted/tizen/6.5/base/20211028.060322 accepted/tizen/base/20210825.055344 accepted/tizen/unified/20190806.220538 submit/tizen/20190806.081640 submit/tizen_5.5/20191031.000007 submit/tizen_5.5_mobile_hotfix/20201026.185107 submit/tizen_5.5_wearable_hotfix/20201026.184307 submit/tizen_6.0/20201029.205502 submit/tizen_6.0_hotfix/20201102.192902 submit/tizen_6.0_hotfix/20201103.115102 submit/tizen_6.5_base/20211028.134101 submit/tizen_base/20210825.043539 submit/tizen_base/20210825.044137 tizen_5.5.m2_release tizen_6.0.m2_release tizen_6.5.m2_release
authorErik de Castro Lopo <erikd@mega-nerd.com>
Thu, 8 Mar 2018 07:00:21 +0000 (18:00 +1100)
committerSeungbae Shin <seungbae.shin@samsung.com>
Tue, 6 Aug 2019 04:22:46 +0000 (13:22 +0900)
The code was allowing files to be written with a channel count of exactly
`SF_MAX_CHANNELS` but was failing to read some file formats with the same
channel count.

Change-Id: Ibe0574a278ccf108a6fe8442ca3a189be19c02ea

src/aiff.c
src/rf64.c
src/w64.c
src/wav.c

index 5107afc..9cd02fb 100644 (file)
@@ -1,5 +1,5 @@
 /*
-** Copyright (C) 1999-2016 Erik de Castro Lopo <erikd@mega-nerd.com>
+** Copyright (C) 1999-2018 Erik de Castro Lopo <erikd@mega-nerd.com>
 ** Copyright (C) 2005 David Viens <davidv@plogue.com>
 **
 ** This program is free software; you can redistribute it and/or modify
@@ -944,7 +944,7 @@ aiff_read_header (SF_PRIVATE *psf, COMM_CHUNK *comm_fmt)
        if (psf->sf.channels < 1)
                return SFE_CHANNEL_COUNT_ZERO ;
 
-       if (psf->sf.channels >= SF_MAX_CHANNELS)
+       if (psf->sf.channels > SF_MAX_CHANNELS)
                return SFE_CHANNEL_COUNT ;
 
        if (! (found_chunk & HAVE_FORM))
@@ -1024,7 +1024,7 @@ aiff_read_comm_chunk (SF_PRIVATE *psf, COMM_CHUNK *comm_fmt)
        psf_log_printf (psf, "  Sample Rate : %d\n", samplerate) ;
        psf_log_printf (psf, "  Frames      : %u%s\n", comm_fmt->numSampleFrames, (comm_fmt->numSampleFrames == 0 && psf->filelength > 104) ? " (Should not be 0)" : "") ;
 
-       if (comm_fmt->numChannels < 1 || comm_fmt->numChannels >= SF_MAX_CHANNELS)
+       if (comm_fmt->numChannels < 1 || comm_fmt->numChannels > SF_MAX_CHANNELS)
        {       psf_log_printf (psf, "  Channels    : %d (should be >= 1 and < %d)\n", comm_fmt->numChannels, SF_MAX_CHANNELS) ;
                return SFE_CHANNEL_COUNT_BAD ;
                } ;
index d57f0f3..876cd45 100644 (file)
@@ -1,5 +1,5 @@
 /*
-** Copyright (C) 2008-2017 Erik de Castro Lopo <erikd@mega-nerd.com>
+** Copyright (C) 2008-2018 Erik de Castro Lopo <erikd@mega-nerd.com>
 ** Copyright (C) 2009      Uli Franke <cls@nebadje.org>
 **
 ** This program is free software; you can redistribute it and/or modify
@@ -388,7 +388,7 @@ rf64_read_header (SF_PRIVATE *psf, int *blockalign, int *framesperblock)
        if (psf->sf.channels < 1)
                return SFE_CHANNEL_COUNT_ZERO ;
 
-       if (psf->sf.channels >= SF_MAX_CHANNELS)
+       if (psf->sf.channels > SF_MAX_CHANNELS)
                return SFE_CHANNEL_COUNT ;
 
        /* WAVs can be little or big endian */
index e508c69..39ff2c9 100644 (file)
--- a/src/w64.c
+++ b/src/w64.c
@@ -1,5 +1,5 @@
 /*
-** Copyright (C) 1999-2017 Erik de Castro Lopo <erikd@mega-nerd.com>
+** Copyright (C) 1999-2018 Erik de Castro Lopo <erikd@mega-nerd.com>
 **
 ** This program is free software; you can redistribute it and/or modify
 ** it under the terms of the GNU Lesser General Public License as published by
@@ -379,7 +379,7 @@ w64_read_header     (SF_PRIVATE *psf, int *blockalign, int *framesperblock)
        if (psf->sf.channels < 1)
                return SFE_CHANNEL_COUNT_ZERO ;
 
-       if (psf->sf.channels >= SF_MAX_CHANNELS)
+       if (psf->sf.channels > SF_MAX_CHANNELS)
                return SFE_CHANNEL_COUNT ;
 
        psf->endian = SF_ENDIAN_LITTLE ;                /* All W64 files are little endian. */
index bcb2153..c21d333 100644 (file)
--- a/src/wav.c
+++ b/src/wav.c
@@ -620,7 +620,7 @@ wav_read_header     (SF_PRIVATE *psf, int *blockalign, int *framesperblock)
        if (psf->sf.channels < 1)
                return SFE_CHANNEL_COUNT_ZERO ;
 
-       if (psf->sf.channels >= SF_MAX_CHANNELS)
+       if (psf->sf.channels > SF_MAX_CHANNELS)
                return SFE_CHANNEL_COUNT ;
 
        if (format != WAVE_FORMAT_PCM && (parsestage & HAVE_fact) == 0)