Commit Graph

2954 Commits

Author SHA1 Message Date
evpobr
6dee7120ab sndfile-salvage: Handle files > 4 GB on Windows OS 2021-03-06 21:44:33 +05:00
evpobr
36c5198d91 common: Fix regression after 4ff3b84 2021-03-06 12:00:31 +05:00
evpobr
61bcb5e979 Fix previous commit 2021-03-06 11:54:08 +05:00
evpobr
4ff3b84eff msvc: Fix annoying conversion warnings #304 2021-03-06 11:41:47 +05:00
evpobr
1578687eb3 common: Move psf_isprint() to source file 2021-03-05 12:02:01 +05:00
evpobr
6477f6cd83 common: Move psf_memdup() to source file 2021-03-05 12:00:54 +05:00
evpobr
db41920b6d common: Move psf_strlcat() and psf_strlcpy() to source file 2021-03-05 11:50:17 +05:00
evpobr
6d77865775 common: Remove unused fourcc_to_marker() function 2021-03-05 11:43:08 +05:00
evpobr
3b8e3ef807 sndfile-deinterleave: Fix large stack allocation 2021-03-04 20:28:58 +05:00
evpobr
bd2f8226d9 chunk: Fix NULL pointer dereferencings 2021-03-04 20:20:52 +05:00
evpobr
bea8fa5d0e common: Fix NULL pointer dereferencing 2021-03-04 20:16:24 +05:00
evpobr
490dcc642f wav: Use proper format specifiers 2021-03-04 20:13:34 +05:00
evpobr
8b31aea3fb sfendian: Fix possible arithmetic overflows 2021-03-04 20:10:40 +05:00
evpobr
96755fa3e5 alac: Fix unitialized value 2021-02-25 13:05:12 +05:00
evpobr
b20886b7ab test_file_io: Use proper format specifiers 2021-02-25 13:02:30 +05:00
evpobr
3078185b6a common: Fix undefined behaviour 2021-02-25 12:58:11 +05:00
evpobr
cab39856af broadcast: Use proper format specifiers 2021-02-25 12:51:30 +05:00
evpobr
c29a002749 sndfile-info: Use proper format specifiers 2021-02-25 12:47:27 +05:00
evpobr
f44d0988e4 alac: Fix NULL pointer dereferencing 2021-02-25 12:41:02 +05:00
evpobr
7e6cc7cb19 ima_adpcm: Fix unitialized value 2021-02-25 12:38:12 +05:00
evpobr
a53048792a alac: Use proper format specifiers 2021-02-25 12:36:35 +05:00
evpobr
2e7b55944a Fix some potential comparisons of a constants 2021-02-25 11:07:53 +05:00
evpobr
a201cf27e9 dither: Fix invalid type casts 2021-02-22 23:01:05 +05:00
bobsayshilol
aa3346cc6e
tests: Make temporary filenames unique per test (#704)
When two tests share a temporary filename they can cause ctest to fail
when run in parallel mode since both would attempt to operate on the
same file if scheduled to run at the same time.

To fix this, filenames in the smaller tests have been individually
renamed, and for the bigger tests a prefix has been added to make them
unique.

The complete list of conflicting filenames (which were then manually
inspected) was generated by running the following command in 'tests':

    for file in $(grep -hoER \"\\w+\\.\\w+\" | sort | uniq -d)
        do echo $file
        grep -Rn $file
        echo
    done | less
2021-02-21 11:11:34 +01:00
bobsayshilol
deb669ee8b ms_adpcm: Fix and extend size checks
'blockalign' is the size of a block, and each block contains 7 samples
per channel as part of the preamble, so check against 'samplesperblock'
rather than 'blockalign'. Also add an additional check that the block
is big enough to hold the samples it claims to hold.

https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=26803
2021-02-21 12:28:47 +05:00
bobsayshilol
a9815b3f22 wavlike: Fix incorrect size check
The SF_CART_INFO_16K struct has an additional 4 byte field to hold
the size of 'tag_text' which the file header doesn't, so don't
include it as part of the check when looking for the max length.

https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=26026
2021-02-21 12:28:47 +05:00
David Seifert
26b4ae781d
Delete temporary files for invalid opus versions
* Previously, temporary files in the testsuite weren't cleaned up
  properly, and would fail if unique filenames (#704) were used.
2021-02-20 16:18:19 +01:00
evpobr
ef03e3c9dd Fix compiler warning 2021-02-19 18:03:08 +05:00
evpobr
ac9a7bbad4 Remove useless union from sf_private_tag struct 2021-02-19 16:50:46 +05:00
evpobr
2a8feebcdb Use UTF-8 as internal path encoding
This is an internal change to unify and simplify the handling of file
paths.

On the Windows platform, the file path is always converted to UTF-8 and
converted to UTF-16 only for calls to WinAPI functions.

The behavior of the functions for opening files on non-Windows platforms
does not change.
2021-02-19 16:44:50 +05:00
evpobr
d11a64c7c4 Deprecate ENABLE_SNDFILE_WINDOWS_PROTOTYPES define
Use standard `_WIN32` define instead. Any sane compiler on Windows
platfrom defines `_WIN32`.

The `wpath` parameter type has been changed to an equivalent type that
does not require the inclusion of the `windows.h` header.
2021-02-18 16:56:34 +05:00
evpobr
d7e17811b1 Update commit message contributing guidlines
Related to #705.
2021-02-18 12:10:30 +05:00
evpobr
5d5eb6fed5 Fix use of flexible arrays with MSVC
Introduced by 0c80547.
2021-02-17 15:14:59 +05:00
evpobr
610c6392cb Fix deprecated function warning
The `GetVersionEx` function  has been deprecated.

Since it doesn't make much sense here, it has been deleted.
2021-02-17 13:44:15 +05:00
evpobr
1f324b7998 Remove file IO dead code
This code has never actually been used.
2021-02-16 10:58:53 +05:00
evpobr
c401533017 Update CHANGELOG.md 2021-02-16 10:44:12 +05:00
Arthur Taylor
3185940301 ogg_vorbis: Improve granule position calculation
Improve granule position calculation, centralising logic in one
function, adding warning messages for malformed data conditions and
commenting about corner and degenerate cases.
2021-02-15 21:37:51 -08:00
Arthur Taylor
abe9dcc0f1 ogg_vorbis: Fix granule position when seeking Vorbis streams
Previously the vorbis_seek function did not take the lapped nature of
Vorbis block into account when using the bisection search.

Also, introduce vorbis_skip(), which can skip through packets without
having to decode all the way to samples.
2021-02-15 21:37:51 -08:00
bobsayshilol
ad2990ec02 Add the generate example to the CMake build 2021-02-15 10:39:58 +05:00
bobsayshilol
9e0e55f8bf Move these magic numbers into the common header and give them some error messages
Without this the client gets the message "Not a valid error number
(666)" printed to stdout, which doesn't explain what the issue is.

These were found via fuzzing where the fuzzer was spamming these
messages.
2021-02-15 10:39:11 +05:00
bobsayshilol
40cb9e3c14 Jump forwards to the next 4 byte aligned offset rather than always jumping backwards by 3 bytes
This was causing an infinite loop on malformed input generated by
fuzzing.

Note that jumping backwards to the previous 4 byte aligned offset also
resulted in the same infinite loop since psf_ftell() was returning an
offset ending in 0xf.
2021-02-15 10:39:11 +05:00
bobsayshilol
678411acba Jump back to the start of guess_file_type() rather than recursing into it
My fuzzer crashes out with a very large stacktrace if this recurses too
many times.
2021-02-15 10:39:11 +05:00
bobsayshilol
3970faeb7f Make sure that there's enough space to store decoded nibbles in when reading IMA ADPCM data
The loop in wavlike_ima_decode_block() that pulls apart the nibbles
assumes that there's 8 nibbles worth of data for every channel, so
rather than adding a branch in the hot path I've opted for allocating
slightly more than we might need.

This was a blocker caught by fuzzing locally.

This also appears to be the same crash as
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=25530.
2021-02-15 10:39:11 +05:00
evpobr
2db6a8fd2e Change SNDFILE type to be a typedef of a real struct
For developers it is typedef to the actual `sf_private_tag` struct now.

For users it is still opaque type (no API break).
2021-02-14 18:34:16 +05:00
evpobr
23daaebc2a Add commit message requirements to CONTRIBUTING.md
1. Separate subject from body with a blank line
2. Limit the subject line to 50 characters
3. Capitalize the subject line
3. Do not end the subject line with a period
4. Use the imperative mood in the subject line
5. Wrap the body at 72 characters
6. Use the body to explain what and why vs. how
2021-02-14 18:32:45 +05:00
bobsayshilol
5ba69401c1
Fix pedantic warnings (#703)
* Fix warnings about incorrect format specifiers.
GCC only wants to see void pointers for %p formatters, so cast as appropriate.

* Fix a warning about an invalid enum value.
The following warning was observed when compiling with -pedantic:

    warning: ISO C restricts enumerator values to range of 'int' (2147483648 is too large)

The values of these enums don't escape wav_read_header() and are only used to set bits in a bitmask, so simply use the next bit rather than jumping to a huge number.

* Give anonymous unions a name.
This fixes the 'anonymous unions are a C11 extension' warning when compiling with -pedantic.

* Use flexible array members rather than zero sized arrays.
This flagged up the following warning when compiling with -pedantic:
    warning: zero size arrays are an extension [-Wzero-length-array]

* Safely return the smallest value of a short.
GCC gives the following warning when compiling with -pedantic:

    warning: overflow in conversion from 'int' to 'short int' changes value from '32768' to '-32768' [-Woverflow]

This looks intentional from the surrounding code, so return -32768 in a legal way rather than depending on undefined behaviour.

* Use the same min/max approach with all compilers.
The GCC specific code gives the following warning from GCC when compiled with -pedantic:

    warning: ISO C forbids braced-groups within expressions [-pedantic]

This code was also a fundamentally different way of calculating min/max since it didn't evaluate the inputs more than once, which meant there was potentially a difference in behaviour when the library was built with different compilers if the evaluation of 'a' or 'b' had side effects.
2021-02-14 10:16:33 +05:00
bobsayshilol
ecb9672aaa
Fix int normalisation when reading in floats with the replacement reader (#702)
* Use the correct scale when normalising an integer read on the fallback floating point path.
Without this the values were only being scaled to a short's max value.

* Add a second pass over the floating point tests that enables the replacement read functionality.
These cover the issue fixed by the previous commit.

* Add an entry to CHANGELOG.md for #702.
2021-02-14 09:45:07 +05:00
evpobr
06fd6f626e Fix more NULL file handle values 2021-02-09 12:55:21 +05:00
evpobr
b11477eeff Use proper error value for Win32 file handle
It is INVALID_HANDLE_VALUE, no idea why we should pretend that it is NULL.
2021-02-08 16:33:37 +05:00
evpobr
dca6f8abbb Fix memory leak in caf_read_header()
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=30375

Credit to OSS-Fuzz.
2021-02-08 09:47:14 +05:00