wavpack: Fix infinite loop when reading broken files (#1304)

A crafted file can have blockSamples set to 0 and a blockSize so big
that when adding 8 it overflows and offset is 0 so it goes back to the
same position and loops forever
This commit is contained in:
tsdgeos
2026-02-04 17:31:59 +01:00
committed by GitHub
parent cf86f20b36
commit f4117f873c

View File

@ -260,16 +260,16 @@ void WavPack::Properties::read(File *file, offset_t streamLength)
const unsigned int flags = data.toUInt(24, false);
unsigned int smplRate = sampleRates[(flags & SRATE_MASK) >> SRATE_LSB];
if(!blockSamples) { // ignore blocks with no samples
offset += blockSize + 8;
continue;
}
if(blockSize < 24 || blockSize > 1048576) {
debug("WavPack::Properties::read() -- Invalid block header found.");
break;
}
if(!blockSamples) { // ignore blocks with no samples
offset += blockSize + 8;
continue;
}
// For non-standard sample rates or DSD audio files, we must read and parse the block
// to actually determine the sample rate.