Commit Graph

4159 Commits

Author SHA1 Message Date
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
Chocobo1 88fb432a0f
Fix nasm.h not found when building in x86
The following is the error from compiler:
Assembling cpu_asm.nasm
  cmd.exe /D /C "C:\Users\appveyor\AppData\Local\Temp\1\tmp62cb769c16c04b79a2f73246c8ccf95a.cmd"
  "/NASM/nasm.exe" -o "FLAC-asm.dir\Release\cpu_asm.obj" -fwin32 -I"C:\project\lib\flac\include\\" -I"C:\project\lib\flac\_build\Win32\\" -D"CMAKE_INTDIR="Release"" -dOBJ_FORMAT_win32 "C:\project\lib\flac\src\libFLAC\ia32\cpu_asm.nasm"
  C:\project\lib\flac\src\libFLAC\ia32\cpu_asm.nasm:34: fatal: unable to open include file `nasm.h'

Closes #220.

Signed-off-by: Ozkan Sezer <sezeroz@gmail.com>
2021-06-22 22:44:18 -07:00
Ralph Giles 88bb6d49a4
Merge pull request #244 from maxz/fix-wrongly-encoded-characters
Fix encoding of contributor name.
2021-06-22 10:44:29 -07:00
Max Zettlmeißl d73631d1ca Fix encoding of contributor name.
The name of Håvard Kvålen was wrongly encoded.
2021-06-22 15:54:09 +02:00
Erik de Castro Lopo 27c615706c github actions: Drop HTML validation
Its seems `xmllint` is mainly an XML validator and not a HTML validator
and can't find a decent command line HTML validator.
2021-03-15 13:46:20 +11:00
Martijn van Beurden ae288c067c Fix compression ratio display for very small files
Because the compression ratio was calculated before processing
the input of the last frame, it did not include the size of this
last frame. This patch moves the calculation of the compression
ratio after the new input has been processed. Now the compression
ratio on very small files is correctly displayed.
2021-03-15 13:46:20 +11:00
Martijn van Beurden ced7f6829d Add some overflow checks for residual bits calculation 2021-03-15 13:46:20 +11:00
Martijn van Beurden 38b7fec143 Change analyse function to support >4Gbit frames
Theoretically, when a rice parameter of 0, 24-bit samples, fixed
predictor with order 0, no rice escaping and a blocksize of 65536
is chosen, a subframe could be up to 2^24*65536 = 1 terabyte in
size. While this obviously should never happen, the analyse
function should be able to debug such a case.
2021-03-15 13:46:20 +11:00
NotTsunami 5f5035d209 flac: Work around gcc bug to prevent false unset MD5 signature warning
A bug beginning in gcc version 9.2 causes strings to get incorrectly
stripped when passed directly to memcmp with a zero first byte (1).
This bug causes flac -t to fail on any .flac file with a md5 checksum
beginning in 00. To work around this bug, the FLAC__byte type is used
for an empty md5 sum to prevent a string from being stripped, which
is backwards compatible and avoids compile-time checks. This was
initially reported back in March 2020, but has seen more light since
Ubuntu 19.10 and up ship with gcc 9.2 as the default compiler. A
patch has been merged into the master gcc branch (2), but has not
been included in any versions as of this commit date.

The initial reporter provided a patch in their bug report (3), which
is included in this PR with authorship attributed to the reporter.

(1) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95189
(2) https://gcc.gnu.org/git/gitweb.cgi?p=gcc.git;h=d5803b9876b3d11c93d1a10fabb3fbb1c4a14bd6
(3) https://sourceforge.net/p/flac/bugs/478/

Closes #192.
2021-03-15 13:46:20 +11:00
Neelkamal Semwal d7b33142ec libFLAC/stream_decoder.c: Fix divide by zero error in FLAC__stream_decoder_seek_absolute 2021-03-15 13:46:20 +11:00
Robert Kausch 159cd6c41a libFLAC/stream_decoder.c: Use current position as bound when seeking 2021-03-15 13:46:20 +11:00
Tim Gates bfd4f13f3e
docs: fix simple typo, opertator -> operator
There is a small typo in oss-fuzz/fuzzing/datasource/datasource.hpp.

Should read `operator` rather than `opertator`.

Signed-off-by: Ralph Giles <giles@thaumas.net>
2020-12-17 11:05:31 -08:00
evpobr ce6dd6b573 CMake polishing
* Improve CPU features detection

  CMAKE_SYSTEM_PROCESSOR is pretty useless (e.g. when compiling with
  MSVC ARM64 toolchain and Ninja still returns system processor).

* Don't build src/utils targets by default

  Fix compilation for UWP platform.

* Add more Visual studio Git ignore patterns
* Autogenerate Doxygen docs
2020-05-14 13:56:01 +10:00
Ulrik Mikaelsson 37e675b777 Simplified logic of parsing sizes of rice-partitions
> if the partition order is zero, n = frame's blocksize - predictor order
> else if this is not the first partition of the subframe,
>   n = (frame's blocksize / (2^partition order))
> else n = (frame's blocksize / (2^partition order)) - predictor order

if the partition order is zero, then partition_number can only be zero
if the partition order is zero, then
  (frame's blocksize / (2^partition order))
  is (frame's blocksize / 1) == frame's blocksize
2020-05-03 17:16:19 +10:00
Thomas BERNARD 4fbb6d4f2e fix build under Mac OS X with PowerPC CPU
revert 44036c9a9b because auxv.h is only
available under Linux and FreeBSD.
2020-05-03 17:14:33 +10:00
evpobr e0b62a61a7 Bunch of CMake fixes
* Add more Git ignore patterns
* Fix Ogg dependency handling (closes #203)
* Remove unneeded compiler flag (closes #204)
* Fix Visual Studio DLL build error error C2491:
  'flac_internal_rename_utf8': definition of dllimport function not
  allowed (closes #205)
* Add alias targets
* Reduce number of CMake files
* Improve CMake intrinsics detection
2020-05-03 17:13:50 +10:00