This fixes the problem noted in #43 where attempting to convert a stereo
WAV to SDS gives a misleading error about the codec, when the real problem
is that the output format only supports mono not stereo.
Signed-off-by: Erik de Castro Lopo <erikd@mega-nerd.com>
We don't play on MacOSX >= 10.8 (the code for the new API is not written),
and support for MacOSX older than that was removed some time ago.
So drop the last remnants; we just don't play on MacOSX.
Currently, libsndfile requires in-tree bootstrapping and creation
of the tarball. For Gentoo, some users might want to build the
latest git checkout. This commit makes out-of-tree building of all
the necessary dependencies possible.
Signed-off-by: Erik de Castro Lopo <erikd@mega-nerd.com>
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.
CVE-2017-14634
Closes: https://github.com/erikd/libsndfile/issues/318
Signed-off-by: Erik de Castro Lopo <erikd@mega-nerd.com>
Explicitly writing the header with SFC_UPDATE_HEADER_NOW before
the first sf_write() was making sf_write() calls fail. This is a
test to verify that the fix works.
Signed-off-by: Erik de Castro Lopo <erikd@mega-nerd.com>
The FLAC__stream_encoder_init_stream() function complains if it is
called multiple times. If we happen to have flushed the header
manually before with sf_command(snd, SFC_UPDATE_HEADER_NOW, ...),
then all subsequent sf_write...() functions fail otherwise because
they attempt to write the header again.
Signed-off-by: Erik de Castro Lopo <erikd@mega-nerd.com>
There was a long standing problem where the compiler was not able to
check format speficiers for `psf_binheader_writef`. This is a standard
problem with using non-standard format specifiers with stdargs.
This solution wraps all non-format parameters pass to that functions
with a macro which performs an explicit type cast. The second step is
to have a Python program make sure these macro wrappers match the
format specifiers.
Closes: https://github.com/erikd/libsndfile/issues/241
Fixes the following problems:
1. Case 's' only enlarges the buffer by 16 bytes instead of size bytes.
2. psf_binheader_writef() enlarges the header buffer (if needed) prior to the
big switch statement by an amount (16 bytes) which is enough for all cases
where only a single value gets added. Cases 's', 'S', 'p' however
additionally write an arbitrary length block of data and again enlarge the
buffer to the required amount. However, the required space calculation does
not take into account the size of the length field which gets output before
the data.
3. Buffer size requirement calculation in case 'S' does not account for the
padding byte ("size += (size & 1) ;" happens after the calculation which
uses "size").
4. Case 'S' can overrun the header buffer by 1 byte when no padding is
involved
("memcpy (&(psf->header.ptr [psf->header.indx]), strptr, size + 1) ;" while
the buffer is only guaranteed to have "size" space available).
5. "psf->header.ptr [psf->header.indx] = 0 ;" in case 'S' always writes 1 byte
beyond the space which is guaranteed to be allocated in the header buffer.
6. Case 's' can overrun the provided source string by 1 byte if padding is
involved ("memcpy (&(psf->header.ptr [psf->header.indx]), strptr, size) ;"
where "size" is "strlen (strptr) + 1" (which includes the 0 terminator,
plus optionally another 1 which is padding and not guaranteed to be
readable via the source string pointer).
Closes: https://github.com/erikd/libsndfile/issues/292