Commit Graph

3662 Commits

Author SHA1 Message Date
Erik de Castro Lopo
efaab3c822 test/ : Use more portable echo constructs
Fix suggested by Daniel Macks.

Closes: https://sourceforge.net/p/flac/bugs/433/
2015-10-04 09:43:38 +11:00
Tristan Matthews
33a73fcba2 microbench: remove duplicate define
Signed-off-by: Erik de Castro Lopo <erikd@mega-nerd.com>
2015-09-30 18:59:05 +10:00
Tristan Matthews
ab300d4b18 microbench: add benchmarking code for Darwin
Signed-off-by: Erik de Castro Lopo <erikd@mega-nerd.com>
2015-09-30 18:58:39 +10:00
Erik de Castro Lopo
d91eb4ae75 libFLAC: Fix an out-of-bounds heap read
When doing a flac to flac conversion, bad data read from the input file
was making it all the way through the encoder to cause a read past the
end of the buffer in the CRC calculation.

Fix had two parts:

* bitwriter.c: Make a debug only assert (assert bits < 32) into a proper
  failure.
* stream_encoder.c: Catch the error condition of wasted bits being greater
  that bits_pers_sample and limit it to the bits_per_sample value.

Found using the American Fuzzy Lop fuzzer.
2015-09-28 09:18:27 +10:00
Erik de Castro Lopo
5fab59f8bc src/flac/encode.c: Fix undefined behaviour
Patch-from: lvqcl <lvqcl.mail@gmail.com>
2015-09-07 15:55:32 +10:00
Erik de Castro Lopo
084bb72f78 test_flac.sh: Test unsigned as well as signed 2015-09-07 15:21:47 +10:00
Erik de Castro Lopo
a9434ddff1 src/test_streams: Generate signed and unsigned RAW files 2015-09-07 15:20:10 +10:00
Erik de Castro Lopo
bb6f643fdc test_streams.sh: Improve error message 2015-09-07 14:49:55 +10:00
Erik de Castro Lopo
9be32a538f flac/decode.c: Fix undefined behaviour 2015-09-04 00:22:48 +10:00
Erik de Castro Lopo
4591b3f2fb test_seeking: Fix undefined behaviour 2015-09-03 14:52:55 +10:00
Erik de Castro Lopo
451efca294 microbench/util.c: Win32 support 2015-09-02 16:34:22 +10:00
Erik de Castro Lopo
98cab352a0 microbench/Makefile.am: Fix 'make distcheck' 2015-09-02 16:33:54 +10:00
Erik de Castro Lopo
95fc3bf314 Add first micro-benchmark 2015-09-01 04:14:17 +10:00
Erik de Castro Lopo
e48ca8d4d7 libFLAC++/metadata.cpp: Fix undefined behaviour 2015-09-01 00:46:42 +10:00
Erik de Castro Lopo
e5ef534497 MSVC: Fix libFLAC_static.vcxproj dependencies
libFLAC_static.vcxproj was missing a dependency on win_utf8_io_static.

Patch-from: lvqcl <lvqcl.mail@gmail.com>
2015-09-01 00:31:51 +10:00
Erik de Castro Lopo
0bea5fb964 flac/encode.c: Fix undefinoed behaviour 2015-08-31 00:22:16 +10:00
Erik de Castro Lopo
3982865e97 libFLAC/bitwriter.c: Fix undefined behaviour 2015-08-31 00:22:12 +10:00
Erik de Castro Lopo
1b8af6bb45 libFLAC/fixed.c: Fix undefined behaviour
Left shift if a negative integer such that the sign bit is affected is
(according to the C spec) undefined behaviour and the residual
calculations using the shift operator were hitting this.

Fortunately these same calculations using plain multiplication do not
invoke UB and according to benchmarking (on x86_64 linux) have the same
performance as the bit shift version.
2015-08-29 05:22:22 +10:00
Erik de Castro Lopo
25d387377a tests: Fix undefined behaviour
Undefined behaviour in the test support code.
2015-08-27 09:34:43 +10:00
Erik de Castro Lopo
a14581642c libFLAC/format.c: Fix undefined behaviour
In the case where seek_table->num_points is zero, seek_table->points
will be NULL and passing that to qsort() invokes undefined behaviour.

Since seek_table->num_points is zero, the only sensible thing to do
is to short circuit return 0.
2015-08-26 17:21:36 +10:00
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