Commit Graph

3792 Commits

Author SHA1 Message Date
Erik de Castro Lopo
fb273e469e libFLAC/stream_decoder.c: Fix undefined behaviour
Found by compiling with -fsanitize=undefined and running the testsuite.
2015-08-24 19:21:51 +10:00
Erik de Castro Lopo
e3c8095336 libFLAC/bitwriter.c: Fix undefined behaviour
Improve folding of signed to unsgned to avoid UB.
2015-08-23 08:51:44 +10:00
Erik de Castro Lopo
b18d8d50bd libFLAC/bitreader.c: Fix undefined behaviour
The function FLAC__bitreader_read_raw_int32() triggered undefined behaviour
when sign extending an unsigned value. The Stanford Grahpics bithacks page
provided an alternative that avoided UB.
2015-08-23 08:50:33 +10:00
Erik de Castro Lopo
d9503c8458 libFLAC/md5.c: Clean up allocation
Make sure ctx->capacity gets updated correctly when safe_realloc()
fails.

Patch-from:  lvqcl <lvqcl.mail@gmail.com>
2015-08-23 07:37:56 +10:00
Erik de Castro Lopo
584a1346c9 libFLAC: Fix memory leak
Leak introduced in commit d9ae5e9128. Thanks to lvqcl <lvqcl.mail@gmail.com>
for pointing it out.
2015-08-22 20:28:47 +10:00
Erik de Castro Lopo
d9ae5e9128 libFLAC: Add function safe_realloc_()
The new function wraps, realloc() and if the realloc() fails, it
free()s the old pointer.

This is an improvement on the potential realloc() memory leak that
was fixed in 15a9062609.

Still needs fuzzing to validate it.
2015-08-22 19:39:37 +10:00
Erik de Castro Lopo
684fb3d544 libFLAC/stream_decoder: Fix double free
The american-fuzzy-lop fuzzer found a couple of instances of double
free() resulting from commit 15a9062609.

The problematic free() were the ones associated with use of the
safe_realloc_mul_2op_() function which can call realloc(ptr,0) which
according to the realloc manpage is already an implicit free().
2015-08-22 19:25:39 +10:00
Ben Boeckel
f7c52c8aa8 metaflac: add --scan-replay-gain option
Signed-off-by: Erik de Castro Lopo <erikd@mega-nerd.com>
2015-08-14 06:21:26 +10:00
Erik de Castro Lopo
15a9062609 libFLAC: Fix potential meory leaks
If the `realloc` function failed, memory would leak.

Patch-from: lvqcl <lvqcl.mail@gmail.com>
2015-08-09 14:32:11 +10:00
Erik de Castro Lopo
7083cf2d90 decoder: Treat negative qlp_shift as an error
Shift by a negative value is undefined behaviour so there is no "right"
way of dealing with this.

Patch-from: lvqcl <lvqcl.mail@gmail.com>
2015-08-09 08:50:35 +10:00
Erik de Castro Lopo
4f84da5dd4 Windows: Ensure FreeLibrary() calls match LoadLibrary() calls
The function get_utf8_argv() was calling LoadLibrary to load msvcrt.dll
but wasn't calling FreeLibrary() if GetProcAddress() fails.

Patch-from: lvqcl <lvqcl.mail@gmail.com>
2015-08-09 08:49:06 +10:00
Erik de Castro Lopo
92285393ca flac/metaflac: Do case-insensitve comparison of hex values
Patch-from: lvqcl <lvqcl.mail@gmail.com>
2015-08-09 08:48:57 +10:00
Erik de Castro Lopo
1123087821 Compat: Fix for MSVC deprecated functions
According to MSDN, stricmp and strnicmp functions are deprecated
since MSVC 2005 and _stricmp/_strnicmp should be used instead.

Patch-from: lvqcl <lvqcl.mail@gmail.com>
2015-08-09 08:42:41 +10:00
Erik de Castro Lopo
c3cf5312c1 autogen.sh: Add --no-symlinks option 2015-08-01 17:54:49 +10:00
Erik de Castro Lopo
9e2bf61d68 autogen.sh: Switch from bash to sh and make it POSIX 2015-08-01 17:47:06 +10:00
Erik de Castro Lopo
6ced857c25 libFLAC: Fix decoder_flush with uninitialized decoder
Closes: https://sourceforge.net/p/flac/bugs/428
2015-07-13 22:20:29 +10:00
Erik de Castro Lopo
cf7442d638 libFLAC/cpu.c: Assume Android has SSE
According to https://developer.android.com/ndk/guides/abis.html#x86
Android always support SSE, so there's no need to test SSE OS support.

Why both __ANDROID__ and ANDROID are tested:
http://stackoverflow.com/questions/15328751/android-macro-suddenly-not-defined
http://stackoverflow.com/questions/6374523/how-to-detect-compilation-by-android-ndk-in-a-c-c-file
https://groups.google.com/forum/#!topic/android-ndk/cf9_f1SLXls

Patch-from: lvqcl <lvqcl.mail@gmail.com>
2015-07-13 22:20:29 +10:00
Erik de Castro Lopo
e771e7b6a7 flac/foreign_metadata: Fix for odd RIFF chunk size
Accept odd values to ckSize of RIFF chunk. FLAC should read these
but should avoid creating them.

Patch-from: lvqcl <lvqcl.mail@gmail.com>
Closes: https://sourceforge.net/p/flac/support-requests/152/
Closes: https://sourceforge.net/p/flac/bugs/419/
2015-07-10 19:22:39 +10:00
Mario Sanchez Prada
5ff15bddeb configure.ac : Pass -fno-inline-small-functions when using GCC 4.7
For some reason, the build fails when using GCC 4.7 due to the implicit
-finline-functions option passed to the compiler when -O3 is enabled,
which does not happen in newer versions of GCC, probably due to some of
the "General Optimizer Improvements" included in 4.8 (see [1]).

Fortunately, we don't need to disable -finline-functions completely but
just do it for "small functions", which is what this patch does.

[1] https://gcc.gnu.org/gcc-4.8/changes.html

Closes: https://sourceforge.net/p/flac/bugs/429/
Signed-off-by: Erik de Castro Lopo <erikd@mega-nerd.com>
2015-07-08 22:20:52 +10:00
Erik de Castro Lopo
0cacc0c09f libFLAC/metadata_object.c: Assign NULL after free()
Patch-from: lvqcl <lvqcl.mail@gmail.com>
2015-07-06 21:30:58 +10:00
Erik de Castro Lopo
a45af0ceaf libFLAC/md5.c: Minor formatting fixes
Patch-from: lvqcl <lvqcl.mail@gmail.com>
2015-07-06 21:29:40 +10:00
Erik de Castro Lopo
ff50779e44 libFLAC: More comment validation
When the allocation for obj->comment fails, set obj->num_comments
to zero.

Patch-from: lvqcl <lvqcl.mail@gmail.com>
2015-07-05 21:21:48 +10:00
Erik de Castro Lopo
5e66846a54 Makefile.am: Remove old cruft 2015-07-05 20:59:15 +10:00
Erik de Castro Lopo
d939b44a20 libFLAC: Improve fix in bc5113007a
The assert that was removed in bc5113007a, was a result of error
handling in read_metadata_vorbiscomment_() which set obj->num_comments
to zero, without freeing obj->comments and setting it to NULL.

This commit also restores the assert that was removed.
2015-07-05 20:57:39 +10:00
Erik de Castro Lopo
bc5113007a libFLAC: Remove un-needed assert
This asset was firing when the build was configured with --enable-debug
and the flac executable was then run under American Fuzzy Lop. Removing
the assert did not cause any other problems, even under AFL.
2015-07-04 16:27:33 +10:00
Erik de Castro Lopo
48ff5ee89d replaygain: Remove dead assignment
Patch-from: lvqcl <lvqcl.mail@gmail.com>
2015-07-04 12:36:28 +10:00
Erik de Castro Lopo
b105f9ad93 libFLAC: Remove un-needed test for NULL before free
Passing a NULL pointer to free() is a no-op.
2015-07-04 12:36:28 +10:00
Erik de Castro Lopo
ccb5a4debd flac: Fix inlining failure warning
Also remove related, but old and irrelevant comment.
2015-07-04 11:51:33 +10:00
Erik de Castro Lopo
d9aa331ce4 grabbag: Replace strncpy with safe_strncpy
Patch-from: lvqcl <lvqcl.mail@gmail.com>
2015-07-04 09:15:27 +10:00
Erik de Castro Lopo
bc1f15db29 Remove old incorrect comment
As discussed on the flac-dev mailing list.

Patch-from: lvqcl <lvqcl.mail@gmail.com>
2015-04-25 08:16:34 +10:00
Tristan Matthews
a84587061c configure: Only use -mstackrealign on i686 for mingw32/os2
Signed-off-by: Erik de Castro Lopo <erikd@mega-nerd.com>
2015-04-19 06:27:20 +10:00
Erik de Castro Lopo
1ed65e5600 configure.ac : Add -mstackrealign whenever we add -msse2.
There have been some (pretty much unconfirmed) reports of problems
with SSE enabled but without this stack alignment flag.
2015-03-31 10:14:29 +11:00
Erik de Castro Lopo
ef9f7998fd src/libFLAC/lpc.c : Restore missing conditional.
Git commit 9c2290ade5 in-correctly removed a conditional around
an fprintf. Thanks to mark4o on #xiph (freenode) for reporting
this.
2015-03-31 10:14:17 +11:00
Erik de Castro Lopo
7566d3d4c1 configure.ac : Tweak for x32 architecture.
The x32 architecture uses and ILP32 (32 bit ints, longs and pointers)
on an x86_64 CPU. Since the CPU is x86_64 we need to set FLAC__CPU_X86_64
even though the pointer size is 32 bits.

Patch-from: Stuart Shelton
Closes: https://sourceforge.net/p/flac/bugs/427/
2015-03-12 08:28:01 +11:00
Erik de Castro Lopo
336f6a5429 configure.ac : Fix FLAC__HAS_X86INTRIN / FLaC__SSE_OS.
* Correct definition of FLAC__HAS_X86INTRIN in config.h file.
* Correct comparison of sse_os with 'true' instead of 'yes'.

Patch-from: lvqcl <lvqcl.mail@gmail.com>
2015-02-25 06:48:34 +11:00
Erik de Castro Lopo
ab7ab03bfa src/test_streams/main.c : Use flac_snprintf() instead of snprintf().
MSVC doesn't have snprintf().

Patch-from: lvqcl <lvqcl.mail@gmail.com>
2015-02-25 06:48:31 +11:00
Erik de Castro Lopo
64d4322b66 ci/flac-autotool.sh : Test 'distcheck' target instead of 'check'. 2015-02-24 18:32:07 +11:00
Erik de Castro Lopo
1ddeb2640e test/test_flac.sh : Make it work for 'make distcheck'.
An output file was being set to read only and hence could not be
overwritten by a later test. Not sure why this only affected the
'make distcheck' target.
2015-02-24 18:32:07 +11:00
Erik de Castro Lopo
29db3fbf1c Fix cursheet tests for 'make distcheck'. 2015-02-24 06:06:10 +11:00
Erik de Castro Lopo
8267168d28 src/encode.c : Fix potential infinite loop in flac-toflac encoding.
A malformed file (generated by AFL) had a 'samples_left_to_process' value
of greater than the actual numbe of samples. When re-encoding the decoder
would get to the end of the file and then continuously return a decode
status of FLAC__STREAM_DECODER_END_OF_STREAM, causing an infinite loop.

Solution is to break out of the loop on two consecutive end-of-stream
events.
2015-02-22 21:44:27 +11:00
Erik de Castro Lopo
ffcda161ad Add file ci/flac-autotool.sh.
Currently only does 'make check' because 'make distcheck' is currently
broken.
2015-02-21 10:04:42 +11:00
Erik de Castro Lopo
c431a6c581 libFLAC/metadata_object.c : Fix typo in comment. 2015-02-21 07:05:21 +11:00
Christian Weisgerber
b5a10e75ed configure.ac : Detect 'amd64' as being same as 'x86_64'.
On BSD systems, the 64-bit x86 architecture is called "amd64".

Signed-off-by: Erik de Castro Lopo <erikd@mega-nerd.com>
2015-02-19 06:13:01 +11:00
Miroslav Lichvar
fed0dfa108 src/libFLAC/stream_decoder.c : Rework fix for seeking bug.
To avoid crash caused by an unbound LPC decoding when predictor order is
larger than blocksize, the sanity check needs to be moved to the subframe
decoding functions.

Signed-off-by: Erik de Castro Lopo <erikd@mega-nerd.com>
2015-02-18 17:19:19 +11:00
Erik de Castro Lopo
033af7bf1c libFLAC : Put upper bound on number of seek points.
Restrict number of seek points to 32768 total and a maximum of two per
second.

Ten hours of content is 36000 seconds which gives about one seek point
for every second for those ten hours. Also, having more than two seek
point per second makes little sense regardless of content length.

Without these restrictions flac-to-flac encoding of a malformed input
file (eg something generated with http://lcamtuf.coredump.cx/afl/)
can result in an attempt to generate a stupidly large number of seek
points and cause an allocation failure.
2015-02-18 10:13:53 +11:00
Erik de Castro Lopo
c06a44969c flac : Fix for https://sourceforge.net/p/flac/bugs/425/
* flac/encode.c : Validate num_tracks field of cuesheet.
* libFLAC/stream_encoder.c : Add check for a NULL pointer.
* flac/encode.c : Improve bounds checking.

Closes: https://sourceforge.net/p/flac/bugs/425/
2015-02-18 09:49:08 +11:00
Erik de Castro Lopo
ed22a42bbe test/test_metaflac.sh : Out-of-tree build fixes. 2015-02-15 20:37:40 +11:00
Erik de Castro Lopo
d8036ea9d6 test/test_flac.sh : Out-of-tree build fixes. 2015-02-15 20:37:40 +11:00
Erik de Castro Lopo
7c3cd3d908 Update grabbag tests to work out-of-tree. 2015-02-15 20:37:40 +11:00
Erik de Castro Lopo
bb2abeaf10 test/test_flac.sh : Silence increased encoding size warnings.
These warning are supposed to occur for files with noise-like
characteristics and some of the tests use files containing noise.
2015-02-15 16:48:46 +11:00