Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: Foobar v2.24.1: FLAC, unsupported format or corrupted file (Read 2798 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Foobar v2.24.1: FLAC, unsupported format or corrupted file

Hey,
I have a problem with a few files from a certain single. Foobar doesn't play them at all, it reports a flac stream error, unsupported format or corrupted file. After removing any metadata with MP3TAG the file becomes readable. flac.exe reports something like this.
Code: [Select]
04-vibeout-im_just_more_(discorockerz_remix)-repack.flac: *** Got error code 4:FLAC__STREAM_DECODER_ERROR_STATUS_BAD_METADATA


04-vibeout-im_just_more_(discorockerz_remix)-repack.flac: ERROR while decoding metadata
                                                          state = FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC

Below is a link to one of the files. What's metadata wrong with it?
Is there a way to workaround the problem or do I have to edit the file?

Thanks

Moderator: removed link

Re: Foobar v2.24.1: FLAC, unsupported format or corrupted file

Reply #1
Another case of FLAC 1.4.x becoming stricter and preventing decoding. I can understand encoder being strict and refusing to encode nonsense, but I don't like that decoder fails to handle so many files in circulation. Flac -t using v1.3.x or v1.2.x don't complain anything about the file and could happily decode it.

If you don't want to touch the files and indeed want a workaround, you could install FFmpeg Decoder Wrapper and configure FLAC to be handled by the wrapper.

Re: Foobar v2.24.1: FLAC, unsupported format or corrupted file

Reply #2
Or use command line decoder to decode with flac 1.3x. Thanks.
Regardless, I'm curious what exactly he doesn't like and what's wrong with these tags.

Re: Foobar v2.24.1: FLAC, unsupported format or corrupted file

Reply #3
Interestingly, metaflac does not complain.

Of course if decoders are not zealous enough, then someone malicious could suitably corrupted flac file that has "a flac stream" hidden in metadata, and so that decoder X plays this part and decoder Y plays that part - but it is getting questionable that not even flac -F can get anything out of something that used to decode just fine.

@ktf  ... something for 1.5?

Re: Foobar v2.24.1: FLAC, unsupported format or corrupted file

Reply #4
Just to be on the safe side, I won't delete the file from Dropbox for the foreseeable future so it can be used for further research.

Re: Foobar v2.24.1: FLAC, unsupported format or corrupted file

Reply #5
but I don't like that decoder fails to handle so many files in circulation
And I don't want to be responsible for yet another security hole somewhere. This file is in fact a perfect example where a naive parser/decoder could run into buffer overflow problems.

The case here: the Vorbis comment block says there are only 11 tags, while there are in fact 19. When I change the byte at offset 0x34B from 0x0B to 0x13, the file parses correctly, and metaflac shows 19 tags instead of 11.

A naive parser could reserve space for 11 tags, but when processing the 12th tag (as the metadata block length says it isn't finished yet) you get a heap overflow -> security hole. Of course one could, like FLAC 1.3.x just assume the block length is correct, but it could very well be the number of tags is correct instead.

I agree the `flac` command line utility should be able to salvage the audio, which it currently cannot.
Music: sounds arranged such that they construct feelings.

Re: Foobar v2.24.1: FLAC, unsupported format or corrupted file

Reply #6
There is no chance of buffer overflow if you verify the indexes at every step. Like the comment parser super carefully does.
Old FLAC just skipped over the extra bytes. In my opinion the correct behavior would be to see that there is extra comment data and try to parse those too.

Re: Foobar v2.24.1: FLAC, unsupported format or corrupted file

Reply #7
I would like FLAC to do the right thing too, but salvaging broken metadata is at the bottom of my list. It is hard to get right, there are a lot of possible scenarios and I don't have a lot of time to work on FLAC. I've been working for months to get the last bugs out of the multithreading code and the code to parse chained files, and fuzzing keeps throwing new ones at me.

So, I could use a little help. If someone wants to improve corrupt metadata handling, I would gladly accept PRs on GitHub or patches over email.
Music: sounds arranged such that they construct feelings.