Skip to content

Commit

Permalink
double64_init: force psf->sf.channels in a reasonable range
Browse files Browse the repository at this point in the history
This prevents division by zero later in the code.

While the trivial case to catch this (i.e. sf.channels < 1) has already
been covered, a crafted file may report a number of channels that is
so high (i.e. > INT_MAX/sizeof(double)) that it "somehow" gets
miscalculated to zero (if this makes sense) in the determination of the
blockwidth. Since we only support a limited number of channels anyway,
make sure to check here as well.

Fixes libsndfile#318
CVE-2017-14634
  • Loading branch information
fabiangreffrath committed Sep 28, 2017
1 parent 7144414 commit 904c515
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/double64.c
Expand Up @@ -91,7 +91,7 @@ int
double64_init (SF_PRIVATE *psf)
{ static int double64_caps ;

if (psf->sf.channels < 1)
if (psf->sf.channels < 1 || psf->sf.channels > SF_MAX_CHANNELS)
{ psf_log_printf (psf, "double64_init : internal error : channels = %d\n", psf->sf.channels) ;
return SFE_INTERNAL ;
} ;
Expand Down

0 comments on commit 904c515

Please sign in to comment.