Commit Graph

4127 Commits

Author SHA1 Message Date
Martijn van Beurden dd8a264c56
Restructure README, API and HTML documentation
Tool documentation has moved to man directory, other dev docs to
README.md and CONTRIBUTING.md. User documentation is already on
the website and doesn't really belong in the source code. Also, fix CMake
so that it uses Doxyfile.in instead of using defaults.
2022-09-05 19:11:31 +02:00
Martijn van Beurden 5e67c6278e
[CI] Add Windows build with shared libs 2022-09-04 15:23:12 +02:00
Martijn van Beurden 5d1402eae3
fuzzer: Do not add corrupt vorbiscomment metadata block
Issue: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=50509
Credit: Oss-Fuzz
2022-08-31 07:10:20 +02:00
Martijn van Beurden a6de25bbb6
Update ABI check 2022-08-30 22:01:11 +02:00
Martijn van Beurden dc12a9e2f6
Add struct tag to FLAC__StreamMetadata (#416) 2022-08-29 20:35:19 +02:00
Martijn van Beurden 0bf7282f58
Protect window functions from NaN
Credit: oss-fuzz
Issue: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=47747
2022-08-23 19:40:35 +02:00
Martijn van Beurden cd031fb7a9
Add ABI check to CI
This adds a dump of current ABIs (which will probably be released
as 1.4.0) to the test directory, and adds a comparison to current
ABIs to the distcheck
2022-08-22 16:07:25 +02:00
Martijn van Beurden c90b3ea3c0 Fix integer overflow in seeking code
This issue popped up in ci-fuzz, unrelated to the PR itself.
2022-08-20 16:03:53 +02:00
Martijn van Beurden 5bc582b2c7 Fix some OOM metadata bugs, disable OOM checking in metadata fuzzing
For now OOM emulation in fuzzer_metadata is disabled, as I really
want to get as much merged as soon as possible. Need to get back
to this at some point
2022-08-20 16:03:53 +02:00
Martijn van Beurden 1f21ae2702 Add write callback abort check to seeking fuzzer
If the write callback calls for an abort, this must be honored.
This commit adds a check to ascertain the write callback isn't
called again
2022-08-20 16:03:53 +02:00
Martijn van Beurden 3ce4475451 Don't overwrite bad state with seek error
In case memory allocation fails or decoding is aborted during
seeking, do not overwrite these states with a seek error
2022-08-20 16:03:53 +02:00
Martijn van Beurden 70e63b03ec Throw memory allocation error when side subframe allocation fails 2022-08-20 16:03:53 +02:00
Martijn van Beurden a2c8ae599e Move entropy partitioning result allocation so it can be checked
For some reason realloc failing to allocate space to store the
results of entropy partitioning was not handled at all. The realloc
is moved to a spot where it is possible to set encoder state. This
also moves it from deep within a loop to being called only
occasionally
2022-08-20 16:03:53 +02:00
Martijn van Beurden c65483e2c2 Do not memset when allocation fails
Also remove some nearby unused code
2022-08-20 16:03:53 +02:00
Martijn van Beurden fbb6cb5c07 Add OOM checking to fuzzing 2022-08-20 16:03:53 +02:00
Martijn van Beurden 707dace4bd Leave metadata items untouched if resize function fails 2022-08-20 16:03:53 +02:00
Martijn van Beurden 21fe95ee82 Add and use _nofree variants of safe_realloc functions
Parts of the code use realloc like

x = safe_realloc(x, somesize);

when this is the case, the safe_realloc variant used must free the
old memory block in case it fails, otherwise it will leak. However,
there are also instances in the code where handling is different:

if (0 == (x = safe_realloc(y, somesize)))
    return false

in this case, y should not be freed, as y is not set to NULL we
could encounter double frees. Here the safe_realloc_nofree
functions are used.
2022-08-20 16:03:53 +02:00
lutianxiong b715d7b9fe fix potential memleak 2022-08-20 16:03:53 +02:00
Martijn van Beurden 35306a812b
Introduce subdivide_tukey apodization
Subdivide_tukey is intended to replace partial_tukey and
punchout_tukey. It works in rougly the same way, but uses a more
efficient algorithm, recyling more data.

subdivide_tukey has 2 arguments, of which 1 is optional. The
first states the maximum number of parts the signal has to be
split up in, the second is the tukey parameter, divided by the
max num of parts.

subdivide_tukey(3) analyses audio with an unsplit block, with the
block split in 2 and split in 3. Here the default p of 0.5 applies
to the smallest parts, so the unsplit block effectively has a p of
0.5/3. subdivide_tukey(3/2e-1) does the same but with p of 0.2.
2022-08-19 20:56:24 +02:00
Martijn van Beurden 6d2492d346
Prepare oom checking in fuzzing
By merging oom checking in fuzzing in steps, it is possible to
implement it without having oss-fuzz build failures
2022-08-19 11:59:16 +02:00
Martijn van Beurden 010c60e1f9
Add configure option to not build programs 2022-08-13 15:20:42 +02:00
Martijn van Beurden 9bc2cc4c3b
Remove really old --explain text and reflow to fit 80 chars
There was some help text in `flac --explain` which hasn't been
correct for about 20 years already. This is removed, the rest of
the text is reflowed to fit 80 chars standard terminal width
2022-08-10 19:12:00 +02:00
Martijn van Beurden 80d064e15d
Convert docbook to markdown
Currently, the man pages are converted from a docbook document, but
the conversion doesn't seem very reliable. Also, the man page is
more-or-less duplicated by the html documentation.

This commit moves all tool documentation to a markdown document which
is readable by itself and can be converted by pandoc to a man page
and can be used by Jekyll to populate the website.
2022-08-09 21:26:19 +02:00
Martijn van Beurden 4f40fa8433
Move changelog to markdown and top directory, add changes in git 2022-08-08 12:55:50 +02:00
pkubaj 349cc0700a
Fix HAVE_GETAUXVAL check for FreeBSD (#410)
FreeBSD doesn't have getauxval().
2022-08-07 21:47:01 +02:00
Martijn van Beurden 3022dad831
Fix and warning for MSVC with Windows XP toolset (#399)
A warning and a small workaround is added for building
libFLAC on MSVC with a specific Windows XP targeting toolset.
2022-08-06 20:32:28 +02:00
Martijn van Beurden 428e681784 [CMake] Don't search for libiconv and libintl on Windows
The functions these libs provide don't seem to be used on Windows
anyway. This fixes https://github.com/xiph/flac/issues/249
2022-08-01 21:02:03 +02:00
Martijn van Beurden 4e823662ec Fix decoding of 33 bps constant subframe 2022-07-31 21:58:07 +02:00
Martijn van Beurden 10e34d444a Also add trailing nul to empty vorbis comment entries
This might fix https://github.com/xiph/flac/issues/48 I cannot
check as I don't have a file to test with. Besides returning an
empty string upon reading, also allocate empty strings when growing
vorbiscomments
2022-07-28 17:44:24 +02:00
Martijn van Beurden 6a9d952f6c Check for vorbis comment entry being not null in fuzzer 2022-07-28 17:44:24 +02:00
Martijn van Beurden 05ff569266 Finish porting guide 2022-07-27 22:16:04 +02:00
Martijn van Beurden 42201ae575 Add porting guide stub 2022-07-27 22:16:04 +02:00
Martijn van Beurden 10d7ce268b Bulk update copyright dates to 2022 2022-07-26 16:23:07 +02:00
Martijn van Beurden c6a4d5c07b
Add FMA intrinsics for autocorrelation calculation
See https://github.com/xiph/flac/pull/387 for details
2022-07-25 12:07:24 +02:00
Martijn van Beurden 67131c04b8 Include stddef.h in compat.h
See https://github.com/xiph/flac/issues/76 for details

Also, move include of stddef.h and stdarg.h up to top of file to
make clear that they are included unconditionally
2022-07-19 17:33:29 +02:00
Martijn van Beurden 99885d3d64 Fix rolled up version of lpc_restore_signal_wide
This fixes https://github.com/xiph/flac/issues/393
2022-07-17 22:32:02 +02:00
Martijn van Beurden d3b8947b73 Improve tempfile generation of fuzzer_metadata 2022-07-16 21:11:16 +02:00
Martijn van Beurden 5186025b94 Re-add check for block align
In 2003, in commit 94f81b0, a check was added for the block align
field in WAVE. If it contradicts other parts of the header, an error
was raised. This was (probably erroneously) made inactive with #if 0
in commit 13c63e4. This commit reactivates the check and removes the
rest of the inactivated code.
2022-07-16 15:19:52 +02:00
Martijn van Beurden 77521a7d67 Eliminate race conditions in fuzzer_metadata file access
See https://github.com/google/oss-fuzz/issues/8006 for details
2022-07-15 07:46:26 +02:00
Martijn van Beurden 48d4f81211
Revert "Enable encoder to use INT32_MIN as residual value" (#389)
This reverts commit 7e0a0e5723,
following the change to the FLAC format proposed here:
https://github.com/ietf-wg-cellar/flac-specification/pull/148

It turns out supporting use of INT32_MIN is quite a hassle.
2022-07-13 20:57:15 +02:00
Martijn van Beurden 43a93a00e4 Only search for backslash in filename on Windows 2022-07-13 09:11:05 +02:00
Martijn van Beurden 772efde6a7 Check first metadata block is streaminfo in level 1 metadata iterator
In simple_iterator_prime_input_ there was no check whether the first
metadata block is a streaminfo block. As the rest of the functions
operate under the assumption the first block is a streaminfo block,
for example to prevent the functions from deleting the last block
and being left with an iterator pointing nowhere, this check is
added.
2022-07-07 22:06:14 +02:00
Martijn van Beurden b963ce0873 Check chain length Ogg FLAC file
When a metadata chain was read from an Ogg FLAC file containing no
metadata (but otherwise valid), an empty chain could be returned,
leading to null derefencing on trying to manipulate it. This commit
adds a check for the chain length
2022-07-07 22:06:14 +02:00
Martijn van Beurden 46f3f36772 Fix dereferencing of null pointer in metadata_iterators.c 2022-07-07 22:06:14 +02:00
Martijn van Beurden f3864bf1f6 Add limits to metadata reading
In commit 0077d3b checks were added for metadata reading in the
stream decoder. However, the metadata interface suffers from the
same problems. Similar to the mentioned commit, checks are added.
2022-07-07 22:06:14 +02:00
Martijn van Beurden da7b9a0ced Add fuzzer_metadata 2022-07-07 22:06:14 +02:00
Martijn van Beurden 7e0a0e5723 Enable encoder to use INT32_MIN as residual value
As abs(INT32_MIN) is undefined, it took some extra work to enable
the encoder to do this. While expected gains are zero, this is
done to ensure full spec coverage in this regard
2022-07-01 21:51:31 +02:00
Martijn van Beurden 633ab36ec5
Small fixes needed for 32-bit capability (#379)
* Change replaygain analysis so it is able to handle 32-bit PCM
* Increase FLAC__REFERENCE_CODEC_MAX_BITS_PER_SAMPLE to 32
* Fix switch-case fallthrough
2022-07-01 07:36:48 +02:00
Martijn van Beurden 10c0a5f610 Add INT64_MAX limit to seekpoints
FLAC seekpoints are coded in unsigned 64-bit ints, but the code
handling them uses signed 64-bit ints. Since users are unlikely
to run into this limit anyway, do not use seekpoints larger than
INT64_MAX

Credit: Oss-Fuzz
Issue: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=48112
2022-06-29 21:33:12 +02:00
Martijn van Beurden cee5a1dcd3 Change eof handing in seeking code
Commit 3fc5ba4 replaced a seeking error with specific handling.
This handling consisted of lowering the upper seek bound.
However, this handling was both slow and wrong. Because it is slow
it causes fuzzing timeouts. It was wrong in that if there was
another valid frame in the boguss frame being read, it would no
longer be reachable.

This commit replaces the handling with another approach: instead of
lowering the upper bound, the lower bound is raised. With this, the
calculation of pos for the next seek is changed and the seeking code
hopefully ends up somewhere not decoding the bogus frame.

If in decoding the frame at lower bound eof is still reached,
a seek error is thrown. This is reasonable, as lower bound should
be after the end of the last frame (not somewhere halfway a frame)
and if a corrupt frame is encountered, proper seeking cannot be
reasonably expected. It could be argued that it is still possible
to try and lower the upper bound by trying to decode a frame by
moving one byte backward at a time, looking for a frame, but this
will probably cause fuzzer timeouts and as said, proper seeking
in such a stream cannot be reaonably expected.

Credit: Oss-Fuzz
Issue: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=48077
2022-06-29 21:33:12 +02:00