Commit Graph

3974 Commits

Author SHA1 Message Date
Martijn van Beurden
14eb65de34 Fix configuration of stack smash protection/fortify source on MinGW
Without this commit, building fails on MinGW because
-D_FORTIFY_SOURCE=2 needs runtime support which MinGW does not
provide. Building was possible with make LDFLAGS='-lssp'

This commit checks whether a symbol used by _D_FORTIFY_SOURCE=2 and
the stack smashing protector are available, and if so, enables these.
Resulting DLLs depend on the libssp DLL.
2022-04-15 09:36:15 +02:00
Martijn van Beurden
7dd7f94822 Fix building both static and shared libs on MinGW with autotools
When building both static and shared libs on MinGW with autotools,
the build broke down without any error message. This commit makes
such a build work
2022-04-15 09:36:15 +02:00
Martijn van Beurden
ecede0bc72 Remove AC_C_VARARRAYS from configure.ac
With autoconf 2.70, the behaviour of AC_C_VARARRAYS has changed,
causing a lot of warnings and as a result a cluttered make output.

Doing some research as to where this comes from, I found an strange
piece of code that seems to rely on a misunderstanding as to VLA's
in C++. As I found, the C++ standard does not have VLA's. The
configure.ac code and some code in libFLAC++ seems to think it does.
This now causes strange behaviour.

This commit removes the code relying on this behaviour and removing
all VLA related autoconf macro's from configure.ac
2022-04-15 09:36:15 +02:00
Martijn van Beurden
13149acddd Remove more obsolete autoconf macro's
Autoconf 2.71 warns about obsolete macro's on running ./autogen.sh.

AC_PROG_CC_STDC is replaced by AC_PROG_CC as recommended by autoupdate

AC_HEADER_STDC has been removed. Autoupdate recommended the following:
> The preprocessor macro `STDC_HEADERS' is obsolete. Except in unusual
> embedded environments, you can safely include all ISO C90 headers
> unconditionally.
2022-04-15 09:36:15 +02:00
Martijn van Beurden
d94a43d5c3 Update configure.ac and m4 files with autoupdate 2.60
Starting with autoconf 2.70, obsolescence warnings are output by
default. To keep the script as compatible as possible, I build
autoconf 2.60 and ran the autoupdate that came with it on
configure.ac and all m4 files.
2022-04-15 09:36:15 +02:00
Rosen Penev
144075a114 add clang-format file
This was generated with whatstyle:

whatstyle.py $(find -name "*.h")

with some minor fixups.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2022-04-14 20:42:01 +02:00
Con Kolivas
24629435bb Add support in the encoder for up to 20 bit sample rates
Now that many DACs support up to 768kHz, add support for these
sample rates to the encoder. Files produced with these sample rates
are already decodable by the reference decoder. Update documentation
and tests accordingly.
2022-04-13 20:32:08 +02:00
Martijn van Beurden
f7e77f627a Build as Release to speed up testing and mute debug output 2022-04-13 17:37:50 +02:00
Martijn van Beurden
31bcbb8662 [CI] Run full test suite on Windows 2022-04-13 17:37:50 +02:00
Martijn van Beurden
ce31a1d51f [CMake] Enable testing through busybox
With this commit, it is possible to run the full test suite on
Windows machines when busybox-w32 is installed. This program is
available through chocolatey with 'choco install busybox'

CMake tests for availability of busybox and use if available. As
chocolatey is the preferred method of fetching software for
Github actions, this commit paves the way for running the full
test suite on Windows for CI
2022-04-13 17:37:50 +02:00
Martijn van Beurden
0ec47a87b4 [CMake] Remove /MT from MSVC flags, causes crashes with shared libs 2022-04-13 17:37:50 +02:00
Martijn van Beurden
db72703f86 [CMake] Set binary and library output dir to objs on Windows
Without this patch, CMake places output binaries and libraries in
the respective source directories, like the autotools build system.
The Visual Studio build system places objects in the objs directory

Because CTest didn't run properly when building shared libs, this
commit changes the CMake behaviour on (NOT UNIX) to that similar
to Visual Studio. That way, DLLs and EXEs are placed in the same
directory and running CTest with the correct DLLs being loaded
is trivial.
2022-04-13 17:37:50 +02:00
Martijn van Beurden
4256c12eac [CMake] Specifically prefer linking with static libssp
As to have a libFLAC.dll with no additional dependencies, linking
with libssp.a is preferred over linking with libssp.dll.a
2022-04-13 17:37:50 +02:00
Martijn van Beurden
6e3089b9bc [CMake] Add BUILD_SHARED_LIBS as options 2022-04-13 17:37:50 +02:00
Martijn van Beurden
805b7dba83 [CMake] Build with -lssp on MinGW 2022-04-13 17:37:50 +02:00
NotTsunami
617efda90d CMake: Make FORTIFY_SOURCE optional
* Also add in checking for libssp for MinGW
2022-04-13 17:37:50 +02:00
Martijn van Beurden
f5efd956d9 [CMake] Create prettier MSVC solution files 2022-04-13 17:37:50 +02:00
Martijn van Beurden
2013738622 [CMake] Add options for better MS Visual Studio building 2022-04-13 17:37:50 +02:00
Martijn van Beurden
be1df4085a Silence clang warnings on alignment of unaligned loads
Clang throws *a lot* of warnings on alignment requirement increase
where no alignment is required at all. This is a results of the
way intrinsics were implemented long ago. See
https://stackoverflow.com/questions/71279668/why-does-clang-complain-about-alignment-on-sse-intrinsic-unaligned-loads

This commit silences these warnings by first casting the pointer
to (const void*) or (void*) before casting the (const __m128i*),
(__m128i*), (const __m256i*) or (__m256i*)

Compiling with and without this patch returns exactly the same
binary for GCC 9.3 and clang 10.0
2022-04-13 13:55:26 +02:00
Silent
179cdce1db cmake: Fix tests with BUILD_CXXLIBS or BUILD_PROGRAMS off
Fixes a regression introduced in 10797d5896
2022-04-13 07:35:33 +02:00
David Callu
6debf337c8 cmake: fix c/cxx compile option use with asm code 2022-04-12 21:37:51 +02:00
NotTsunami
2bf5f6ecc9 flacdiff: Add format specifier to prints
printf/fprintf prefer format specifiers rather than variable strings
(despite the const status). No functional change.

Fixes the following compiler reported warning:
warning: format not a string literal and no format arguments [-Wformat-security]
2022-04-12 13:03:22 +02:00
Martijn van Beurden
7b73bbcca4 Move initialization of state up in stream_encoder_new
In stream_encoder_new, set_defaults_ was called before setting
encoder->protected_->state to uninitialized. However, this state
was being accessed by set_compression_level in set_defaults_. As
this is undefined behaviour, move the initialization of
encoder->protected_->state up to before calling set_default_
2022-04-11 21:38:06 +02:00
Martijn van Beurden
4a8ec07e95
Add checks that supplied samples are bounded within bits-per-sample
The encoder did not check whether samples provided through
FLAC__stream_encoder_process or FLAC__stream_encoder_process_interleaved
were bounded to fall within the set bits_per_sample (bps). This created
all kinds of trouble within the encoder, as there are numerous times
where the encoder chooses between different datapaths, data types and
encoding strategies based on the set bps.

https://sourceforge.net/p/flac/bugs/468/ also proved that invalid FLAC
files have been created with libFLAC in the past because of this

See https://github.com/xiph/flac/pull/273 for detailed description of
the commit

Credit: Oss-Fuzz
Issue: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=19758
Issue: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=31727
2022-04-11 20:13:09 +02:00
Ralph Giles
2610594d04
Update maintainer statement.
Erik hasn't had time to look after the repo lately. We continue
as we can.

Signed-off-by: Ralph Giles <giles@thaumas.net>
2022-02-20 20:54:23 -08:00
Ralph Giles
01faa6c644
Set release date in the changelog.
Missed this in the previous commit.

Signed-off-by: Ralph Giles <giles@thaumas.net>
2022-02-20 20:54:22 -08:00
Ralph Giles
22816c6c1b
Set release date for 1.3.4.
This is a target date, but it's a nice round number if we're able
to make it work.

Signed-off-by: Ralph Giles <giles@thaumas.net>
2022-02-20 20:54:20 -08:00
Martijn van Beurden
e75495be3d
Change version to 1.3.4 and add placeholders for release date
Signed-off-by: Ralph Giles <giles@thaumas.net>
2022-02-20 20:54:19 -08:00
Martijn van Beurden
c86def849b
Add 1.3.4 to changelog
Signed-off-by: Ralph Giles <giles@thaumas.net>
2022-02-20 20:54:17 -08:00
Ralph Giles
e548ea38d4
Run CIFuzz on the 1.3.x release branch.
Make sure we have coverage when working on backports to the
older stable API series.

Signed-off-by: Ralph Giles <giles@thaumas.net>
2022-02-20 20:54:06 -08:00
Martijn van Beurden
a2fe43f64e
Change sourceforge URL in flac error messages to github
Signed-off-by: Ralph Giles <giles@thaumas.net>
2022-02-13 21:19:59 -08:00
Martijn van Beurden
e8143ab527
Add CIFuzz to workflows
Signed-off-by: Ralph Giles <giles@thaumas.net>
2022-02-10 20:10:59 -08:00
Martijn van Beurden
79e462fb61
Check that blocksize is evenly divisible by 2^(partition order)
Credit: Oss-Fuzz
Issue: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=38815

Signed-off-by: Ralph Giles <giles@thaumas.net>
2022-02-08 20:49:14 -08:00
Martijn van Beurden
2f209573d0
Check for predictor order <= blocksize in subframe header
Credit: Oss-Fuzz
Issue: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=38347

Signed-off-by: Ralph Giles <giles@thaumas.net>
2022-02-08 20:49:13 -08:00
Martijn van Beurden
d4a7221046
Mark fixed subframes with bps > 24 as unparsable
Like 1fd178e, decoding fixed subframes with bps > 24 results in
integer overflow

Signed-off-by: Ralph Giles <giles@thaumas.net>
2022-02-08 20:49:12 -08:00
Martijn van Beurden
aa126b8f2f
Mark 32 bps stream with stereo decorrelation as unparsable
Credit: Oss-Fuzz
Issue: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=19234

Signed-off-by: Ralph Giles <giles@thaumas.net>
2022-02-08 20:49:11 -08:00
Neelkamal Semwal
e1575e4a7c
libFlac: Exit at EOS in verify mode
When verify mode is enabled, once decoder flags end of stream,
encode processing is considered complete.

CVE-2021-0561

Signed-off-by: Ralph Giles <giles@thaumas.net>
2022-02-08 20:49:09 -08:00
Martijn van Beurden
479f6038d9 Make decoder more fuzzer-friendly by disabling frame checks on fuzzing
This commit disables CRC and zero-bit checking when
FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION is defined
2022-02-08 20:24:32 -08:00
tmkk
b358381a10
cpu.h: detect AVX/FMA intrinsics availability on clang
Previously the FLAC__AVX2_SUPPORTED macro is defined, but actually
AVX2 functions are not used when built with clang because flac only
uses them when FLAC__AVX_SUPPORTED macro is set.

Signed-off-by: NotTsunami
2021-07-24 22:15:17 -07:00
Ralph Giles
313ab5852f github actions: Add dummy ctest config switch.
This is required on windows, but not on other platforms.
It needs to be the default `Debug` target, rather than
`Release` to match CMAKE_BUILD_TYPE, for the $TARGET_FILE
mapping to produce the correct path.

See https://gitlab.kitware.com/cmake/cmake/-/issues/20283
2021-07-11 13:53:07 -07:00
Ralph Giles
10797d5896 cmake: add some simple tests on windows platforms.
The main test harnesses are written in unix shell script, so
they don't work on windows. A stanza was added to the cmake
config to skip all tests there to get a green build.

This is misleading, since no testing was done at all on Windows.

Instead, construct a separate set of tests on non-unix platforms,
calling the two api test programs, which of necessity are
compiled executables. Also invoke the two front-end programs
with just the --help switch to verify they at least start.

Thanks to Marcus Asteborg for the suggestion.
2021-07-11 13:53:07 -07:00
Ralph Giles
bac77f73f2 github actions: Split CMake build into separate steps.
Failures within multi-line commands aren't detected properly
in the windows runner environment. Therefore split each
line into a separate step for the cmake build.

Use the `working-directory` key to mark the build subdir without
having the prepend a `cd` command.
2021-07-11 13:53:07 -07:00
Ralph Giles
21a217e737 github actions: add a windows cmake target
Make use of the available builders for Microsoft Windows build
converage.

Unfortunately this job reports finding no tests to run, despite
being identical to other builds. Worse, this is not reported as
an error.

Windows doesn't have a package manager like linux and macos, so
until we figure out how to build and cache the ogg dependency
for the windows job, just skip ogg support.
2021-07-11 13:53:07 -07:00
Ralph Giles
df35f5ea41 github actions: archive logs on failure.
The test harnesses log details to files during the run,
which is helpful when debugging issues which are only
reported as a run failure in the console output.

When the build job fails, upload an artifact consisting
of a zipfile with all the log files from the build,
so users can investigate test failures in ci more
easily.
2021-07-11 13:53:07 -07:00
Ralph Giles
37d1a620eb github actions: Fix typo.
This doesn't change the build; it just corrects a label.
2021-06-26 05:12:56 +00:00
Ralph Giles
b7a4402aeb gitlab-ci: Add build configs.
Define builds for gitlab's continuous integration runners so we
some feedback on versions of the code hosted there, particularly
https://gitlab.xiph.org/xiph/flac.

Build with GNU Autotools, with CMake+ninja, and verify
the Makefile.lite build.

This uses the same Debian-based docker.io/library/gcc:9 container
image we use for most of the codec projects. That container
doesn't specify an unprivileged user so that we can install
packages.

However, some of flac's file-creation tests must be run as an
unprivileged user who owns the source tree. We therefore
create a user account and use `su` to run the tests.

In the case of the autotools job, `make distcheck` unpacks
the packaged source, so this takes care of ownership.

In the case of the other jobs, we must `chown` the entire
checkout and complete the build as the unprivileged user.

Another way to address this would be to define a custom
container image with the prerequisites installed before
switching to an unprivileged user for the entire build.

The current approach was simpler to get working.
2021-06-26 05:12:56 +00:00
TGMarkiewicz
bab58c374f Fix building/installing docs with CMake
Details:
 - During the installation of the package with CMake, it stops
   (via fail) when doc files should be copied. It was caused by
   changing current binary to current source CMake directory.
2021-06-24 15:59:31 -07:00
TGMarkiewicz
1ac2a6314b Fix version & requires fields in pkg config files
Details:
 - When building with CMake, pkg-config files flac.pc and flac++.pc
   are not updated with Version information. This causes a failure
   when running a configure script in opus-tools
   (https://github.com/xiph/opus-tools).

   Note that OGG_PACKAGE is set to "ogg" exactly as in the configure.ac,
   but it is only set when the building explicitly with libogg.
2021-06-24 15:59:09 -07:00
Andrey Astafyev
a9557c13fa
examples: Fix error condition processing
Don't attempt to attach failed metadata objects. This also avoids
clobbering the error flag if attaching the objects should succeed.

There may still be problems later, for example calling _delete()
on a possibly null metadata object pointer, but this it at least
and improvement in the compromise between error handling and
readability in C.

Signed-off-by: Ralph Giles <giles@thaumas.net>
2021-06-23 13:24:22 -07:00
Ewout ter Hoeven
eba0ff8d3e
CI: Run on pull requests and once a month
Run the CI on PRs and once a month (to detect failures due to updated images or dependencies).

Signed-off-by: Erik de Castro Lopo <erikd@mega-nerd.com>
Signed-off-by: Ralph Giles <giles@thaumas.net>
2021-06-22 22:52:45 -07:00