Commit graph

65 commits

Author SHA1 Message Date
William Wilgus
9367ef1ed6 [BugFix] Fix some Shif related UB -- ASAN
these are the low hanging fruit identified by ASAN

cast the byte values before shift

Change-Id: Ifc5645354a10c15ccd09d1343e1705857a51e011
2023-01-04 22:00:25 -05:00
William Wilgus
972810f6cf strlcpy finish cleanup
remove strlcpy & strlcat from string.h

document suspicious strlcpy call

convert strlcat.h users to string-extra

Change-Id: I313e75db86385c0e6d1aee75d252093be4935f60
2022-11-17 01:54:46 -05:00
Aidan MacDonald
9e93796407 buffering: remove bufgettail/bufcuttail
These operations can only be used in limited circumstances and have
exactly one user. bufgettail especially seems of dubious value; how
often do you need to read N bytes from the end of a file without
changing the file position?

strip_tags() was the only function using them, to strip off ID3v1
and APE tags off the end of buffered tracks. This would save only
32-192 bytes per track -- if the container format uses APE/ID3v1.
It hardly seems worth the effort.

Change-Id: I8fc3c1408517eda6126e75e76d76daea904b50eb
2022-04-20 16:51:49 -04:00
Aidan MacDonald
fca7b8e2ff Fix undefined behavior that blocks compiling with UBSan
Left shifts are not defined in C if they would cause signed overflow,
so these expressions get instrumented, which makes them unusable as
switch values and triggers compile errors when compiling with UBSan.

Change-Id: I0588d4be1e00ba1cfde0eac119ead368b20d10c9
2022-04-17 11:37:34 -04:00
William Wilgus
01d2979bce [COV] metadata module, fix uninit warnings #2
decrease size hit of initializing asf by using a union
remove init from bytes LE conversion in metadata common
-- bad idea for performance

Change-Id: I4514adc125e5da2b99d9f913ba74afd5f1345822
2022-03-20 09:56:44 -04:00
William Wilgus
2a88ec50cd [COV] metadata module, fix uninit warnings
Change-Id: Ifeb22642d7fb683542ff9dcfca0bc58c91ab5f38
2022-03-20 09:10:57 -04:00
William Wilgus
542609bb31 metadata.c fix red
comma, helpful

Change-Id: Iaa352cf1b542f1b805278af8560a6927684dc8d2
2022-03-14 17:38:55 -04:00
William Wilgus
9b4e784560 BUGFIX string_option parsers
fix bugs introduced in the switch over to using string_option
instead of if else strcmp trees,
embedded album art should work again
skin parser had an error for 'noborder' and 'nobar'

Change-Id: I957d81e5fa8467b33bbd93d63c4428c36100acca
2022-03-14 17:23:18 -04:00
William Wilgus
2352cef6d0 replace more strcmp if then trees with string_option()
1

Change-Id: Ic89bbb2ab41068d09c7bd9caa5ba7f38749b9084
2022-03-13 14:31:02 -04:00
William Wilgus
a62d36d9e7 Warble builds define WARBLE fix metadata_common in warble builds
Change-Id: Ie5115162da5a06d917de09f75b90254bb30b7513
2022-03-13 11:41:30 -04:00
William Wilgus
77e4dd81f5 option_string clean-up and consolidate with metadata_common
Change-Id: I2649f6af37bd871fb8f181ae2f716ff0bcf1f65c
2022-03-13 10:55:47 -04:00
William Wilgus
a9c62f2c39 metadata_common.c optimize parse_tag
Change-Id: I84ad404fdcc9698b9d08e6e9c37929f4b7bf569f
2022-03-13 01:40:42 -05:00
William Wilgus
235e41578b metadata/mp3data.c init vars & add sanity checks
Change-Id: Idface0ea73c4a6f0d46a57bddf77db9475a972f4
2021-08-11 22:40:09 -04:00
William Wilgus
30945f1180 metadata/metadata_common.c check read for proper bytes read
Change-Id: I25d7c20d449cde4d5cfd3f57e00ff45f4c14f60b
2021-08-11 22:25:20 -04:00
William Wilgus
f05a7a10a6 metadata/metadata_common.c WS changes
Change-Id: Ieef86e94676c603a21cbb5af55e63ba628a09cdf
2021-08-11 22:16:19 -04:00
William Wilgus
7aa0e0a898 metadata/asf.c ensure variable init & add sanity checks
Change-Id: If4432549b843cafb000c3fedee12184d75da595b
2021-08-11 22:06:15 -04:00
William Wilgus
e3e72d6dba metadata/mp4.c fix small oversight / bug
didn't set the genre string to null on case entry
means read failure would leave genre string indeterminate

add explicit NULL & leave genre uninitialized

Change-Id: I1452a0b57985646c982ec80755d0df9d03745f1e
2021-08-11 08:29:02 -04:00
William Wilgus
c9e9558044 metadata/mp4.c check for read errors skip buffer appropriately
WIP

Change-Id: I770f0d911f7d9826e89d886892ff3913661a8151
2021-08-11 01:36:32 +00:00
William Wilgus
0a6d7abd13 metadata/asap.c consolidate read char function and check return values
and a bit of cleanup using macros to make the code easier to follow

Change-Id: I2c5953a68a9f415453e508c14a9c1a5a1e84e6b5
2021-08-07 17:13:09 -04:00
William Wilgus
da778a1783 metadata/asap.c WS cleanup
Change-Id: Id3bc053a45eeea107a54dd47640fa3ceb4b04498
2021-08-07 17:07:32 -04:00
William Wilgus
57293f1fd9 metadata/vfx.c cleanup string and character handling
Change-Id: I7550d6db05b0d31a1433d0af9b2233f9dc3f5ee2
2021-08-07 04:50:14 +00:00
William Wilgus
603e749c1d metadata/smaf.c handle read errors
Change-Id: I450f1fc8e1b69ce09f9888f5384c3e23a93822a1
2021-08-07 02:53:28 +00:00
William Wilgus
8a8fd3d4a3 metadata/mp3data.c set data to 0 in case of read error
Change-Id: I15d4e3d3be4bf4531c892f4351355b0b2e8e0ca9
2021-08-06 20:55:11 -04:00
Aidan MacDonald
6b1b7b6016 Fix use of uninitialized variable in mp4 metadata parser
Change-Id: Idca69e7429af13609785755d4e152d87f471c462
2021-08-06 16:10:41 +00:00
Solomon Peachy
9f0f2c6658 metadata: Fix sign extension in get_uint64_le() routine
Change-Id: Ibd85cf72ac1babd1fa636c341b90b76bdfc0491b
2021-08-05 13:44:39 +00:00
William Wilgus
0501af8b06 metadata/flac.c fix potential buffer overrun
Change-Id: Iee12f251455c4fda9d91d10e466d17e5e02046b9
2021-08-02 03:00:01 +00:00
William Wilgus
247731fe8c id3tags.c check for buffer overrun
Change-Id: I74fde8e234fe85abfabefddcea7f10038167c715
2021-08-01 22:29:14 -04:00
Solomon Peachy
2ed4bf8a43 FS#13299: Handle MP3 files with more than 128K of headers before audio data
Encountered a file with ~600K of ID3v1 headers.

Optimize the potential overhead by minimizing reverse seeks.

Change-Id: I972dbf1af1c36659f19c7ab4eed0b9149c642880
2021-06-16 17:37:29 -04:00
Solomon Peachy
fa9ddd5af9 Revert "FS#13299: Simplify VBR frame parsing in the metadata decoder."
This reverts commit 756c0d2ac8.

Change-Id: I5f98972f69e7645239fd9218c9d4eeb9bd2ec7a5
2021-06-16 16:58:47 -04:00
Solomon Peachy
756c0d2ac8 FS#13299: Simplify VBR frame parsing in the metadata decoder.
The old code would seek forward by the frame length, expecting to see a
frame header there, perform a validity check, and then seek back to the
current header.

Unfortunately this doesn't handle situations where there is extra padding
between the frames, leading us to potentially read garbage, causing the
validity tests to fail and rejecting the file outright.

Instead, keep track of the previous valid header/position, and if we find
"valid" headers in a row return the first after seeking back to it.

This change allows the file referenced in FS13299 to be properly parsed, but
further work is needed to get the file to be playable.  (file reports itself
as layer 1, variable bit rate, variable sample rate!)

Change-Id: I85f61a6360cc041a172db4b7a6b5516e5b60ceee
2021-06-13 12:13:03 -04:00
Solomon Peachy
942b1dd072 FS13094: Fix a divide-by-zero crash parsing zero-length WMA/ASF files
Change-Id: I2e90692327c69c4467a586b23b877c596b8d2c40
2021-05-12 18:22:06 -04:00
Christian Soffke
a8846e3003 Increase id3v2 max item size on high mem targets
As per multiple user requests:
https://forums.rockbox.org/index.php/topic,53319.msg

The acceptable size for id3v2 fields currently maxes out at
240 bytes on targets with more than 2MB of memory.

The comments field, especially for Podcasts, can sometimes
contain significantly more characters than Rockbox allows.

The limit for devices with more than 8MB of memory
is increased to 500 bytes for individual fields, and
to 1800 bytes for the buffer containing all fields.

Change-Id: I4593372229158756f102f67bcc4a43e64f632d58
2021-03-22 02:50:51 +00:00
Solomon Peachy
670812a44a Support MP3 audiostreams embedded in ASF containers.
Full credit to Igor Poretsky

Change-Id: I54769e33665cada1e1e0ef3a5511b56c8e1b859a
2021-02-28 16:11:54 +00:00
Solomon Peachy
bdc3dd4fca MP4: append mdat sections together in metadata parser
mp4 files can have multiple 'mdat' chunks.  This is common for
audiobooks, where there is often a secondary mdat containing the
chapter names, but it's also legal to have multiple mdat chunks
for a single logical "track"

This confuses the mp4 metadata parser, which assumes there is
only a single mdat, and always uses the last mdat seen to
determine the "filesize" of the data we're trying to decode.

Work around this by appending each mdat's size to result in the final
"filesize"

Change-Id: I3e7a7efb0f05ef965e8d77f79e450c957524a480
2021-02-19 13:35:41 +00:00
Solomon Peachy
4231c2c83f codecs: Add support for the 'VTX' ZX Spectrum chiptunes format.
This codec requires floating point.

Original author:  Peter Sovietov
Ported to Rockbox:  Roman Skylarov
Further integration and bugfixes:  Solomon Peachy

Change-Id: I781ecd3592dfcdbbc694063334350342534f1d6c
2020-10-09 11:39:25 -04:00
Solomon Peachy
8c7780bafc flac: fix warning introduced in 5758a05
Change-Id: I649f7c356b8b790d6dfbd071a8e391a84d0cdcca
2020-08-10 14:32:40 -04:00
Yuxuan Shui
5758a055fb Handle EOF properly in get_flac_metadata
Change-Id: I5e581990046a9f4a0859787aff2fd6fc06fbf7f5
2020-08-10 14:14:58 -04:00
Solomon Peachy
658026e626 [4/4] Remove HAVE_LCD_BITMAP, as it's now the only choice.
Note:  I left behind lcd_bitmap in features.txt, because removing it
would require considerable work in the manual and the translations.

Change-Id: Ia8ca7761f610d9332a0d22a7d189775fb15ec88a
2020-07-24 21:20:13 +00:00
Solomon Peachy
8cb555460f [3/4] Completely remove HWCODEC support
'swcodec' is now always set (and recording_swcodec for recording-capable
units) in feature.txt so the manual and language strings don't need to
all be fixed up.

Change-Id: Ib2c9d5d157af8d33653e2d4b4a12881b9aa6ddb0
2020-07-24 21:20:13 +00:00
Moshe Piekarski
e884140eae Add support for ID3 tags embedded in AIFF files
Change-Id: I15eb50b6ba1c26052f08e01861f47faede3b9b3b
2020-07-15 18:30:07 +00:00
Solomon Peachy
17a367e0c4 FS#12966: display '+' for positive replaygain values
Change-Id: I976d5511096c2d4d19eb14fa1c6adf8dd3cd9006
2020-07-09 22:18:25 +00:00
Moshe Piekarski
59454f93b3 Add support for some native AIFF metadata fields
Change-Id: I710480a119e0a9b930a13184ed6571fd2dc1bd01
2020-06-22 18:04:40 +00:00
James D. Smith
3cc3e600fe Get APEv2 tag album art format from magic number. Also support bmp artwork.
Change-Id: I81d8f79f47f09528e2f7fa462e579350451c81f1
2020-04-26 13:05:39 -06:00
Solomon Peachy
22c6326974 Improvements for vbrfix plugin:
* Properly account for ID3v1 tags
 * Play time computation fixes
 * Add speech feedback

Patch by Igor Poretsky

Change-Id: Ia6df8fb171882a88527cfa9d3b76b705f09becdd
2019-08-13 17:07:07 +02:00
Solomon Peachy
928557bb17 AAC bitstream format files support
Files with extension "aac" in ADTS or ADIF format are now playable.

Full credit goes to Igor Poretsky.

Change-Id: I413b34e15e5242fea60d3461966ae0984080f530
2018-12-22 20:12:10 -05:00
Solomon Peachy
9b9b30bd54 Realmedia related codecs fixes and enhancements
* More tolerance to the file format variations.
 * AC3 coded files in realaudio format are now playable

Full credit to Igor Poretsky

Change-Id: Id24e94bc00623e89fb8c80403efa92f69ab1e5d7
2018-12-22 20:12:10 -05:00
William Wilgus
ed63ef077a Fix overlapping string region ape.c->read_ape_tags
Switch to strrchr to find the extension

Change-Id: Id7ea01ecc2e0553f560308f8b0fc53bd33b023e5
2018-12-08 20:30:12 +01:00
Amaury Pouly
ce39850e6b rbcodec: remove useless include
metadata.c does not need cuesheet.h, which in apps/ and has nothing to do with
rbcodec library.

Change-Id: I914a49e8c182f5c367d7db3479c2ff39565e5f07
2017-07-30 14:32:12 +02:00
Amaury Pouly
d7871914ac Fix dangerous casts
On Windows 64-bit, the size of long is 32-bit, thus any pointer to long cast is
not valid. In any case, one should use intptr_t and ptrdiff_t when casting
to integers. This commit attempts to fix all instances reported by GCC.
When relevant, I replaced code by the macros PTR_ADD, ALIGN_UP from system.h

Change-Id: I2273b0e8465d3c4689824717ed5afa5ed238a2dc
2017-02-04 17:24:47 +01:00
Michael Giacomelli
d924c83066 Fix warning in WMA Pro and remove a c++ comment.
Change-Id: Id9b50c1fdeca4d87f158da717de8958330f027ef
2014-11-28 23:04:50 +01:00