Commit Graph

3103 Commits

Author SHA1 Message Date
Arthur Taylor
043c9d8a8b ogg: Check for NULL returns from ogg_sync_buffer (issue 863) 2022-12-13 13:04:06 +05:00
evpobr
d8503a6645 Fix clipping of non-int32 numbers
Thanks @umlaeute.
2022-11-19 17:31:26 +05:00
Mads Kiilerich
c59207ef9e src/wavlike.c: fix typo 2022-10-27 09:58:02 +05:00
Mads Kiilerich
0a52a40111 tests/cpp_test.cc: improve error reporting in check_title
The test somehow briefly failed for me. This will help debug if it happens again.
2022-10-27 09:58:02 +05:00
Mads Kiilerich
e2c38cd5c4 src/common.c: psf_log_printf should not emit ASCII control characters with %M 2022-10-27 09:58:02 +05:00
Mads Kiilerich
1534936c10 src/wavlike.c: let wavlike_subchunk_parse consistently consider bytesread when checking chunk_size 2022-10-27 09:58:02 +05:00
Mads Kiilerich
b4de424959 src/wavlike.c: let wavlike_subchunk_parse consistently use cleanup_subchunk_parse
The special logging for zero markers doesn't seem more relevant than for
all the other error handling cases.
2022-10-27 09:58:02 +05:00
Mads Kiilerich
c9ee5f2ff2 src/wavlike.c: Drop wavlike_subchunk_parse unreachable error handling code
We already read the chunk type so bytesread is always > 0, and
(chunk_size >= chunk_length) will thus always have been covered by
(bytesread + chunk_size > chunk_length) just above.
2022-10-27 09:58:02 +05:00
Mads Kiilerich
140b241837 src/wavlike.c: Fix wavlike_subchunk_parse default logging
Follow the general convention and only use '***' for errors. But when
chunk_size is too big, log it as "too big" as for DISP_MARKER etc.
2022-10-27 09:58:02 +05:00
Mads Kiilerich
bc2e8bebe4 src/wavlike.c: Fix wavlike_subchunk_parse skipping of erroneous subchunks, closes #374
Drop invalid +4 as in 65eabcbf7.
2022-10-27 09:58:02 +05:00
Mads Kiilerich
cc5be43f09 tests/error_test.c: introduce wav_list_recover_test to cover #374
The test is currently been negated so it expects to hit the problem.
That will change when the problem is fixed.
2022-10-27 09:58:02 +05:00
Arthur Taylor
0faf893fd2 mpeg_decode: Fix bug where bytes from mpg123_read where ignored.
Most every read api I've ever worked with return no error and positive
byte counts, or zero bytes and an end or error condition. When the end
of stream is reached, the last read will contain the last bytes, and the
next call to read returns an error indicating that end has been reached.

But not mpg123, no, when reaching the last bytes, it returns the last
bytes AND sets the error condition to done.

Assumptions make and ass of you an mumptions.
2022-10-03 08:50:34 -07:00
David Seifert
005a36b41b
Remove autogen.sh
* Users should just use `autoreconf -vif` instead of brittle autogen.sh scripts.

Fixes: #878
2022-09-24 12:51:49 +02:00
David Seifert
bc11600986
configure.ac: fix broken --enable-ossfuzzers option
* Passing `--disable-ossfuzzers` would actually enable fuzzers.
2022-09-13 10:30:28 +02:00
Jörn Heusipp
3bd5048f8c Define SF_COUNT_MAX as INT64_MAX.
INT64_MAX instead of 0x7FFFFFFFFFFFFFFFLL avoids type discrepancy between int64_t and LL (long long) suffix when int64_t is not long long.
2022-09-12 18:54:29 +02:00
Jörn Heusipp
bd951f9a47 Make sndfile.h independent of build system variables
Fixes <https://github.com/libsndfile/libsndfile/issues/868>.
2022-09-12 10:39:37 +02:00
IOhannes m zmölnig
cefd7b59df tests: Use fuzzy comparison in test-suite
Using exact comparison ("a == b") when comparing expected with computed
test data fails the test-suite on many architectures (including, but not
limited to armhf and arm64).

Instead, use epsilon(for now, FLT_EPSILON and DBL_EPSILON) to compare
floating point numbers for equality.


Closes: https://github.com/libsndfile/libsndfile/issues/866

Signed-off-by: IOhannes m zmölnig <zmoelnig@iem.at>
2022-09-09 13:04:00 +05:00
Benjamin Moody
36216ba105 flac: fix reading a large number of samples at once
When reading a FLAC file, the internal function flac_read_loop is used
to read a block of samples and copy them to the application-provided
output buffer.  The 'len' argument to flac_read_loop is the total
number of samples to read (i.e., duration times number of channels.)

Various fields in the FLAC_PRIVATE structure, as well as local
variables in various internal functions, are 'unsigned', which means
that trying to read into a buffer larger than UINT_MAX will cause
problems.  To avoid these problems, each function that calls
flac_read_loop breaks up the operation into buffers of at most
0x1000000 (2^24) total samples.

However, flac_read_loop will also fail (due to the condition at line
224) if the requested 'len' is not a multiple of the number of
channels.  Consequently, if an application tried to read:

 - more than 5592405 frames at once from a three-channel FLAC file
 - more than 3355443 frames at once from a five-channel FLAC file
 - more than 2796202 frames at once from a six-channel FLAC file
 - more than 2396745 frames at once from a seven-channel FLAC file

then sf_read_* or sf_readf_* would incorrectly fail and return zero.

As a simple fix, change the internal size limit from 0x1000000 to
0x690000 (2^16 * 3 * 5 * 7).  This is still quite arbitrary, but is
guaranteed to be divisible by the number of channels (which must be
between 1 and 8); it also ought to be large enough to avoid any
performance overhead, and small enough to be easy to test.
2022-08-06 11:24:33 +05:00
Justace Clutter
53e7dee234
Remove samplerate < SF_MAX_SAMPLERATE requirement (#851)
Related to #850.

Co-authored-by: evpobr <evpobr@gmail.com>
2022-07-11 13:32:40 +05:00
Shaohua Li
a4f1387ab8 Update g72x.c
Fixing signed integer overflow as reported in https://github.com/libsndfile/libsndfile/issues/757 . A similar fix was applied before https://github.com/libsndfile/libsndfile/pull/818
2022-05-31 13:10:26 +05:00
evpobr
a17e32fda6 Use Visual Studio 2022 for GitHub Actions 2022-04-18 13:51:26 +05:00
Michael Cho
e4fdaeefdd configure.ac: substitute EXTERNAL_MPEG_LIBS in sndfile.pc 2022-04-18 13:36:44 +05:00
Stefan Westerfeld
a67c601b0c Support skipping large wav chunks on stdin.
Some wav files can have rather large chunks with chunk types that are
not supported by libsndfile at all. For those, header_seek will just
skip the whole chunk.

This commit makes skipping the chunk work even if the input is stdin
(which doesn't support psf_fseek), by reading over the header using
psf_fread in that case.
2022-04-12 14:01:51 +05:00
Arthur Taylor
718e305dc1 ogg: Correct Opus-assumption of gp rate in _seek_page_search() 2022-04-11 12:16:03 -07:00
Arthur Taylor
7c2053ac96 ogg: convert helper macros to inline functions, documentation updates 2022-04-11 12:16:03 -07:00
Arthur Taylor
bbe95850d9 sndfile.h: Fix accidental command enum reuse for GET_OGG_STERAM_SERIALNO 2022-04-11 12:16:03 -07:00
Arthur Taylor
5c79b98890 ogg_opus: Rename page seeking funcitons 2022-04-11 12:16:03 -07:00
Arthur Taylor
79e654fe6b ogg_opus: Rearange seek pre-roll logic 2022-04-11 12:16:03 -07:00
Arthur Taylor
fdeb8438ad ogg_opus: Fix preskip of granulepos offset files 2022-04-11 12:16:03 -07:00
Arthur Taylor
08c34a81a5 ogg_opus: Cleanups and robustness fixes to seek_page_search 2022-04-11 12:16:03 -07:00
Arthur Taylor
63338de798 ogg_opus: Fix double-counting of len on seek_null_read 2022-04-11 12:16:03 -07:00
Arthur Taylor
66bbb78801 ogg_opus: Grow pre-roll based on experimentation, update comments 2022-04-11 12:16:03 -07:00
Arthur Taylor
70175e9cc1 ogg: Use macros for undocumented ogg_stream state queries. 2022-04-11 12:16:03 -07:00
Arthur Taylor
b56aba5633 ogg: Correct various psf_log_printf() argument length issues. 2022-04-11 12:16:03 -07:00
Arthur Taylor
3aab1c5617 ogg: Add command SFC_GET_OGG_STREAM_SERIALNO
Add command SFC_GET_OGG_STREAM_SERIALNO returning the current stream
serialno. Useful for debugging.
2022-04-11 12:16:03 -07:00
Arthur Taylor
3baa16571f ogg: Fix for issue-794, buffering of searched page is wrong.
The function ogg_stream_seek_page_search() is a reimplementation of
op_pcm_seek_page from libopusfile. This original function contained a
bug a bug caused by a non-braced if body followed by two statements that
should be conditional. Being non-braced, only the first statement was
conditional.

The bug caused previous-page buffering always to be on. Previous page
buffering is an efficiency gain for seeking to positions that are part
of a continued packet. Erroneously always turning it on prevents the
loading of the correct page at the end of the search in some conditions.

This manifested as seek-search working for some positions and not
others, depending on the order of found pages near the final target.
2022-04-11 12:16:03 -07:00
evpobr
83e583dd2c Fix typo 2022-04-06 10:18:19 +05:00
evpobr
d6f83cd4fe gsm610: Fix signed integer overflow
Related to libsndfile#785

Co-authored-by: evpobr <evpobr@gmail.com>
2022-04-06 10:05:41 +05:00
evpobr
fc298c9d93 Fix build on UWP platform, closes #824 2022-04-03 12:13:29 +05:00
evpobr
269ae40a3b Fix CMake build from Autotools tarball, closes #816 2022-04-03 12:05:00 +05:00
evpobr
eff5f0a640 cmake: fix LAME dependency search 2022-04-03 11:41:07 +05:00
David Seifert
33e765ccba
Remove obsolete SF_PLATFORM_S64() macro 2022-04-02 20:53:09 +02:00
David Seifert
ea3ac90e98
Release 1.1.0 2022-03-27 13:48:57 +02:00
evpobr
89e7c02464 Prepare to release 2022-03-27 15:31:49 +05:00
David Seifert
ce57da8fd4
Only add -Wno-format-truncation when using GCC
* Clang produces warnings such as
  warning: unknown warning option '-Wno-format-truncation' [-Wunknown-warning-option]
2022-03-27 13:20:49 +02:00
evpobr
4b01368fd8 Update CHANGELOG.md 2022-03-19 09:32:03 +05:00
evpobr
77acc6d362 cmake: Add config-file package MPEG dependency 2021-12-16 12:57:05 +05:00
evpobr
59f1622c42 cmake: Export targets from the build tree 2021-12-16 12:57:05 +05:00
AdamKorcz
f44c8dbe1d
Fuzzing: Add CIFuzz (#796) 2021-12-14 08:32:18 +05:00
Felix Lange
ca2008903f
sndfile-convert: fix typo in error message (#793)
Co-authored-by: evpobr <evpobr@gmail.com>
2021-11-24 09:52:36 +05:00