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
* Using AX_RECURSIVE_EVAL to determine the full absolute path
and printing it inline in the configure script is less
brittle than calling another script from configure.
Unfortunately ABI was broken when symbols files were removed
in favour of new visibility control of exported functions.
Visibility control with -fvisibility works fine, but symbol
scripts had another feature - versioned symbols. And we lost it.
Since we can not make our symbols to be versioned with the new
approach, it's decided to return everything back.
* CMake: Restore symbol files generation
* CMake: Python is required to build shared libraries
* Autotools: Restore symbol files generation
Closes: https://github.com/erikd/libsndfile/issues/268
Unfortunately this bug cannot be found by the compiler and the tests
didn't find it either. It was found during work to improve the type
safety of calls to psf_binheader_writef.
make_sine.c: fix typo in output message.
make_sine.c: use return instead of exit in main.
make_sine.c: unify error messages.
make_sine.c: return error code if malloc fails.
make_sine.c: free memory and close file handle in error case.
This code had egregious errors in the way things were being passed
to psf_binheader_writef and neither the compiler nor the tests
caught it. It was however found when adding safety macros to enforce
correct type being passed to psf_binheader_writef.