Commit Graph

3087 Commits

Author SHA1 Message Date
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
evpobr
89bed47c45 Add CHANGELOG.md
Other changes:

* Rename the old `NEWS` file to `NEWS.OLD`.
* Update documentation links.
2021-02-01 09:15:19 +05:00
evpobr
251a435566 Fix typo
Thanks to @dvzrv.
2021-01-26 10:21:35 +05:00
SmiVan
5cb3faf69b Marked unimplemented dither enums in the header file as such. 2021-01-24 21:47:57 +05:00
David Seifert
d60deb5d86
Release 1.0.31
Fixes #693
2021-01-24 13:22:23 +01:00
David Seifert
2789000100
Add include/sndfile.h to .gitignore 2021-01-24 13:22:22 +01:00
evpobr
942ae829be
Update NEWS 2021-01-24 12:37:47 +05:00
evpobr
6a3df24db4
Add info about current maintainers and releaser
Related to #609
2021-01-23 18:10:18 +05:00
zodf0055980
4fe1c6a0b3 fix api.md table error 2021-01-20 13:35:08 +05:00
evpobr
288764df09 Fix use of uninitialized value in endswap_int64_t_array
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=25366

Credit to OSS-Fuzz.
2021-01-19 20:38:31 +05:00
Maki
2221cbedd7 Renamed oga to ogg in simple_formats 2021-01-12 16:34:22 +05:00
yuan
9113112445 Improve handling of SMPL chunks in WAV files.
fixes #675
2021-01-06 14:42:31 +05:00
Arthur Taylor
b91c260346 id3: Identify ID3v2.2 and ID3v2.4 headers
Identify ID3v2.2 and ID3v2.4 headers. Previously only ID3v2.3 headers
were identified.
2021-01-05 09:02:40 -08:00
Arthur Taylor
39d8458904 id3: Fix skip of large ID3v2 headers
Fix a bug in id3.c where large ID3v2 headers would fail to seek to the
embedded file. ID3v2 tags are skipped over, treating the wrapped file as
an embedded file. id3_skip() sets the embedded file offset to be just
after the ID3v2 tag ends, then seeks the psf_binheader() to the
fileoffset.

psf_binheader_read() accomplishes seeks by either reading and buffering
bytes until the offset is reached, or if the buffer would be too large,
seeking the underlying file instead using psf_fseek(). psf_fread does
not take the embedded file offset into account, while psf_fseek() does.

In the case of ID3 tags larger than the binheader buffer max, this has
the effect of seeking to twice the id3v2 tag length, as
psf_fseek(fileoffset, SEEK_CUR) adds the fileoffset to the offset
argument again. This lands in the middle of a stream which then cannot
be identified.

To resolve the issue, seek the binheader BEFORE setting the embedded
file offset.

An as-yet unresolved issue is that as skipping forward by seeks is not
supported on pipes, id3_skip() of large ID3v2 tags does not work on
pipes.
2021-01-05 09:02:40 -08:00
evpobr
d03045b014 Fix GitHub actions CI macOS job 2020-12-21 15:54:25 +05:00
evpobr
71250037c7 Document SFC_GET_DITHER_XXX and SFC_SET_DITHER_XXX commands
Closes #674.
2020-12-21 15:27:58 +05:00
SmiVan
bc8a01657b Fixed typos in command documentation. 2020-12-18 18:19:59 +05:00
Tim Gates
bf15a91fb0 docs: fix simple typo, suppiled -> supplied
There is a small typo in src/sndfile.c.

Should read `supplied` rather than `suppiled`.
2020-12-12 10:44:08 +05:00