Commit Graph

2488 Commits

Author SHA1 Message Date
Erik de Castro Lopo
ada48f59f5 share/utf8/charset.c: Cleanup realloc() usage
This version should be logically identical to the previous version
but prevents a false-positive from the cppcheck static analysis
tool.
2017-01-19 20:31:34 +11:00
Erik de Castro Lopo
1e9e707c6f stdint.h fixes for MSVS 2005/2008
This adds a new msvc2005_int.h header file which is "force included"
as needed by the MSVS project file.

Patch-from: lvqcl <lvqcl.mail@gmail.com>
2017-01-19 06:33:33 +11:00
Erik de Castro Lopo
78d67ff870 getopt.c: Pointer comparison fix
* Remove <stdint.h> because MSVC 2005 (and probably 2008) don't have it.
* Fix pointer difference caclulation between `nameend` and `nextchar`.

Patch-from: lvqcl <lvqcl.mail@gmail.com>
2017-01-17 19:41:31 +11:00
David Seifert
c80a819bd7 Only compile and run tests when running 'make check'
Signed-off-by: Erik de Castro Lopo <erikd@mega-nerd.com>
2017-01-17 06:36:10 +11:00
Erik de Castro Lopo
64b7142a36 Final unsigned fixes
Found using the Makefile.lite build system.
2017-01-16 19:31:25 +11:00
Erik de Castro Lopo
9bb7a7e0f5 Yet more unsigned fixes 2017-01-16 18:28:31 +11:00
Erik de Castro Lopo
f60a8ccc5c bitmath.h: MSVS unsigned fix
The orignal code had `unsigned long` inside `#ifdef MSVC`. It was then changed
to `uint64_t` which was incorrect because on Windows `sizze long == 4`.
Change it now to `uint32_t` which is always correct regardless of OS, compiler
or architecture.
2017-01-15 16:28:16 +11:00
sezero
d178058028 libFLAC/cpu.c: Replace memory.h include with string.h
cpu.c was the only source to use memory.h instead of string.h.

Signed-off-by: Erik de Castro Lopo <erikd@mega-nerd.com>
2017-01-15 13:19:01 +11:00
David Seifert
ce6ab95db3 When using libtool, use LTLIBICONV instead.
* This is required, as otherwise -Wl,--as-needed could fail.

Signed-off-by: Erik de Castro Lopo <erikd@mega-nerd.com>
2017-01-15 12:38:56 +11:00
Erik de Castro Lopo
8967db0cb0 bitmath.h: More unsigned fixes 2017-01-15 12:20:52 +11:00
Erik de Castro Lopo
71b909b7a4 Yet more purging of unsigned type 2017-01-15 09:48:42 +11:00
sezero
733afdbe68 flac/utils.c: Workaround for DJGPP missing wcswidth()
Signed-off-by: Erik de Castro Lopo <erikd@mega-nerd.com>
2017-01-14 18:33:03 +11:00
sezero
31b219f0bf Support nasm coff obj format for djgpp
Signed-off-by: Erik de Castro Lopo <erikd@mega-nerd.com>
2017-01-14 18:32:49 +11:00
Erik de Castro Lopo
c6318e9dd3 Purge usage of unsigned type
As pointed out by Ozkan Sezer, on some platforms `int32_t` is actually
a typedef for `long` so `unsigned` cannot be used interchangably with
`FLAC__uint32`. Fix is to switch from `unsigned` to explicit sized ISO
C types defined in <stdint.h>.
2017-01-14 17:46:02 +11:00
Erik de Castro Lopo
6ecd1a2607 libFLAC/cpu.c: Fix build issue on OpenBSD/i386
Patch-from: Christian Weisgerber <naddy@mips.inka.de>
2017-01-13 21:31:00 +11:00
Erik de Castro Lopo
8f25d680ac stream_encoder.c: Make compression_levels_ array const
As pointed out by github user @randomascii, the `compression_levels_`
struct could and should be const.

Closes: https://github.com/xiph/flac/issues/26
2017-01-06 20:01:22 +11:00
Erik de Castro Lopo
58a81cf678 Fix build with MSVC if UNICODE is enabled
Patch-from: "lvqcl.mail" <lvqcl.mail@gmail.com>
Closes: https://sourceforge.net/p/flac/bugs/447/
2017-01-04 06:31:52 +11:00
Erik de Castro Lopo
230cffe08f libFLAC/cpu.c: Fix CPU detecton
Patch-from: Janne Hyvärinen <cse@sci.fi>
2017-01-03 04:46:24 +11:00
Erik de Castro Lopo
ac39d3719f Version 1.3.2 2017-01-01 14:54:28 +11:00
Erik de Castro Lopo
b799a823b9 libFLAC: Remove commented out assert
Pointed out by c.helmrich@ecodis.de. It was added during debugging
in commit c06a44969, but was never meant to stay.
2016-12-24 22:05:22 +11:00
Erik de Castro Lopo
23ca12850c libFLAC/cpu.c: Add CPP guard 2016-12-21 16:16:13 +11:00
Erik de Castro Lopo
76c25ba870 More Makefile.lite fixes
Patch-from: Robert Kausch <robert.kausch@freac.org>
2016-12-21 16:14:50 +11:00
Erik de Castro Lopo
9e5dd48473 Makefile.lite fixes
Patch-from: Robert Kausch <robert.kausch@freac.org>
2016-12-11 20:17:52 +11:00
Erik de Castro Lopo
2f84030092 Fix PACKAGE_VERSION in MSVC files
Patch-from: "lvqcl.mail" <lvqcl.mail@gmail.com>
2016-12-11 20:12:04 +11:00
Erik de Castro Lopo
582f111a83 libFLAC/metadata_object.c: Fix typo in number
As pointed out by Evan Ramos there was typo, `32786` instead of
`32768`.
2016-12-06 20:05:38 +11:00
Erik de Castro Lopo
7b91f2383b libFLAC/cpu.c: Improve logic
Only call `FLAC__cpu_have_cpuid_asm_ia32` if `FLAC__HAS_NASM` is
defined.

Patch-from: "lvqcl.mail" <lvqcl.mail@gmail.com>
2016-12-06 20:05:38 +11:00
Erik de Castro Lopo
0ff8984384 Update version in MSVS project files 2016-12-05 19:52:29 +11:00
Erik de Castro Lopo
6b00dc26b2 Another bulk update of copyright dates 2016-12-05 19:07:13 +11:00
Erik de Castro Lopo
6a5fe43b7e Bulk update copyright dates 2016-12-05 06:35:39 +11:00
Erik de Castro Lopo
a0f2345b72 vcxproj: Remove unused config flags
Specifically, FLAC__NO_SSE_OS and FLAC__SSE_OS.

Patch-from: "lvqcl.mail" <lvqcl.mail@gmail.com>
2016-12-05 05:33:21 +11:00
Erik de Castro Lopo
8a78aad1b9 libFLAC/cpu.c: Whitespace fixes
Patch-from : lvqcl.mail <lvqcl.mail@gmail.com>
2016-12-04 17:41:45 +11:00
Erik de Castro Lopo
1abd8794ca libFLAC/cpu.c: Remove OS SSE detection
Assume that all OSes that are usable today support SSE.

Patch-from: lvqcl.mail <lvqcl.mail@gmail.com>
2016-12-04 17:37:01 +11:00
Erik de Castro Lopo
979ea74606 src/share/grabbag/seektable.c: Fix typo inside assert
Patch-from: "lvqcl.mail" <lvqcl.mail@gmail.com>
2016-12-02 18:02:57 +11:00
Erik de Castro Lopo
a2420c1405 cpu.c: Really fix compiler warnings 2016-09-12 17:27:11 +10:00
Erik de Castro Lopo
d1c15b4fc1 cpu.c: Fix compiler warning on PowerPC 2016-09-11 13:54:15 +10:00
Erik de Castro Lopo
23f6a35996 Fix compiler warning from gcc-6.1.1 2016-09-08 20:39:48 +10:00
Max Kellermann
a52177b0d1 stream_decoder: reset has_seek_table before read_metadata_seektable_()
If a seek table has already been read successfully, then the
has_seek_table flag is true.  Now imagine the file comes with another
seek table, which doesn't make sense, but libFLAC accepts it happily.
If reading this second seek table fails (for example allocation
failure), read_metadata_seektable_() returns false, but the
has_seek_table flag is still true.  If the calling application happens
to ignore this failure, and at some point tries to seek, the process
will crash due to NULL pointer dereference.  This would sure be an
application bug that needs to be fixed, but libFLAC's internal state
is inconsistent, so let's fix this up.

Signed-off-by: Erik de Castro Lopo <erikd@mega-nerd.com>
2016-07-14 18:42:05 +10:00
Max Kellermann
f7491f9741 stream_decoder: fix memory leak after seek table read error
When read_metadata_seektable_() fails, the has_seek_table flag is
never set to true, and thus free() is never called.

Example valgrind output:

 11,185,464 bytes in 1 blocks are definitely lost in loss record 62 of 62
    at 0x4C2BC0F: malloc (vg_replace_malloc.c:299)
    by 0x4C2DE6F: realloc (vg_replace_malloc.c:785)
    by 0x40A7880: safe_realloc_ (alloc.h:159)
    by 0x40A7911: safe_realloc_mul_2op_ (alloc.h:205)
    by 0x40AB6B5: read_metadata_seektable_ (stream_decoder.c:1654)
    by 0x40AAB2D: read_metadata_ (stream_decoder.c:1422)
    by 0x40A9C79: FLAC__stream_decoder_process_until_end_of_metadata (stream_decoder.c:1055)

It is easy to craft a FLAC file which leaks megabytes of memory on
every attempt to open the file.

This patch fixes the problem by removing checks which are unnecessary
(and harmful).  Checking the has_seek_table flag is not enough, as
described above.  The NULL check is not harmful, but is not helpful
either, because free(NULL) is documented to be legal.

After running this code block, we're in a well-known safe state, no
matter how inconsistent pointer and flag may have been before, for
whatever reasons.

Signed-off-by: Erik de Castro Lopo <erikd@mega-nerd.com>
2016-07-14 18:42:05 +10:00
Erik de Castro Lopo
c12bfa0e72 libFLAC: Fix cpuid detecton on old Cyrix CPUs
Some old CPUs (eg Cyrix) set EDX but not ECX when executing CPUID.
One of the solutions is to clear ECX before calling cpuid. From
https://bugzilla.mozilla.org/show_bug.cgi?id=1096651#c9 bug

Patch-from: lvqcl <lvqcl.mail@gmail.com>
2016-07-13 19:47:11 +10:00
Erik de Castro Lopo
74e751c421 libFLAC: Set decoding status if write callback failed
Previously, it the write callback failed the error status
would be set to `FLAC__STREAM_DECODER_READ_FRAME`. Now it
gets set to `FLAC__STREAM_DECODER_WRITE_STATUS_ABORT`.

Patch-from: lvqcl <lvqcl.mail@gmail.com>
2016-07-13 19:42:25 +10:00
Erik de Castro Lopo
293acefe77 libFLAC/metadata_object.c: Clean up
* Remove Yoda conditionals.
* Drop some un-needed asserts.
2016-07-10 17:09:48 +10:00
Erik de Castro Lopo
a70fcdd633 metadata_object.c: Remove un-needed asserts
These asserts were being triggered by AFL (American Fuzzy Lop) and
serve seemingly no useful purpose. The are only enabled in debug builds
where they abort the program which is otherwise in a safe state.

Removing these asserts will potentially allow AFL to turn up other
problems elsewhere.
2016-07-10 11:25:39 +10:00
Max Kellermann
9949ce15f6 stream_decoder: fix integer underflow due to malformed wasted_bits
It is pretty easy for a malformed FLAC file to underflow the "bps"
variable.  In the debug build, this results in an assertion failure in
FLAC__bitreader_read_raw_uint32():

    FLAC__ASSERT(bits <= 32);

In non-debug builds, this simply makes
FLAC__bitreader_read_raw_uint32() fail because
bitreader_read_from_client_() doesn't find enough buffer space for
2**32-1 bits.  But since the failing FLAC_ASSERT() is reasonable, this
should be caught in the FLAC__bitreader_read_raw_uint32() caller.

Signed-off-by: Erik de Castro Lopo <erikd@mega-nerd.com>
Closes: https://github.com/xiph/flac/pull/13
2016-07-10 08:19:26 +10:00
Max Kellermann
0a49fe7788 stream_decoder: check state==ABORTED after process_single() for seek
FLAC__stream_decoder_process_single() ignores frame_sync_() errors,
which means the caller cannot rely solely on the boolean return value,
it is also required to check the new "state".

After FLAC__stream_decoder_process_until_end_of_metadata(),
state==SEARCH_FOR_FRAME_SYNC and
last_frame.header.number_type==FRAME_NUMBER.  When an application
seeks at this time, but an I/O error occurs, then
FLAC__stream_decoder_process_single() returns true, but no frame has
been read yet, i.e. last_frame.header.number_type is still
FRAME_NUMBER.  This triggers the assertion in
seek_to_absolute_sample_():

 FLAC__ASSERT(decoder->private_->last_frame.header.number_type == FLAC__FRAME_NUMBER_TYPE_SAMPLE_NUMBER);

So what needs to be done is check for state==ABORTED after the
FLAC__stream_decoder_process_single() call.

This bug can be triggered remotely with the Music Player Daemon
(https://www.musicpd.org/), and crashes the process.

Signed-off-by: Erik de Castro Lopo <erikd@mega-nerd.com>
Closes: https://github.com/xiph/flac/pull/12
2016-07-10 08:19:26 +10:00
Erik de Castro Lopo
8279778735 flac++.pc.in: Make flac a private requires
Patch pulled from Debian package.

Description:
Chain::Status::as_cstring uses FLAC__Metadata_ChainStatusString which
is in libFLAC. Since the function is inline, every program calling
this function must also link with -lflac, but this is missing in
flac++.pc.

Bug-Debian: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=713645
2016-07-09 21:56:36 +10:00
Erik de Castro Lopo
51fc948746 libFLAC/cpu.c: Fix dfprintf macro for MSVS 2016-07-01 07:04:28 +10:00
Erik de Castro Lopo
bba26a551f libFLAC/cpu.c: Add parens to avoid compiler warnings 2016-06-28 18:08:12 +10:00
Julian Calaby
42c5de6e44 libFLAC/cpu.c: Inline *_disable_avx()
Also only print out OS AVX status if AVX is actually enabled.
2016-06-28 18:08:12 +10:00
Julian Calaby
eae338e0e6 libFLAC/cpu.c: Move cpu_id_ex into cpu_info_x86()
This simplifies the C code without complexifying the preprocessor
code.
2016-06-28 18:08:12 +10:00
Julian Calaby
79ca23ece3 libFLAC/cpu.c: Eliminate a branch in cpu_info_x86
Inverting all the if statements allows us to move the common code of
setting all the registers to zero outside the #if statement.
2016-06-28 18:08:12 +10:00