flac: Explicitly reject FLAC files with more than two channels (FS#13306)

It's not clear that we've ever intended to support >2ch files, based on
'#define MAX_CHANNELS 2' and other logic that only seems to care about
mono vs not.

Change-Id: I15e92fb29cceef32e63fc3a821f6e96bbde930b6
This commit is contained in:
Solomon Peachy 2024-10-14 08:53:43 -04:00
parent 542eeae11c
commit 772eff8ca6

View file

@ -156,6 +156,12 @@ static bool flac_init(FLACContext* fc, int first_frame_offset)
fc->channels = ((buf[12]&0x0e)>>1) + 1;
fc->bps = (((buf[12]&0x01) << 4) | ((buf[13]&0xf0)>>4) ) + 1;
if (fc->channels > MAX_CHANNELS) {
LOGF("FLAC: Too many channels (%d > %d)\n",
fc->channels, MAX_CHANNELS);
return false;
}
/* totalsamples is a 36-bit field, but we assume <= 32 bits are
used */
fc->totalsamples = (buf[14] << 24) | (buf[15] << 16)